Activity Forums Salesforce® Discussions How to unit test code which has logic around the created date in Salesforce?

  • Prachi

    Member
    August 22, 2019 at 5:00 am

    Hi Laveena,

    You can create sObjects in memory with arbitrary CreatedDate values by using JSON.deserialize. This doesn’t enforce the normal read-only field attributes that prevent you from setting a createdDate value. However, you can’t commit arbitrary CreatedDate values to the database (or else it would be a serious security issue).
    Detecting governor limits through apex
    First of all, the exception thrown by hitting a limit, System.LimitException is uncatchable and means that your script will be killed, even if it happens inside a try/catch block. There is a class, Limits, that contains a number of static methods that allow you to check your governor limit consumption.

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos