+ Start a Discussion
VAHBVAHB 

Test for Cases

I am creating a test case on a Trigger that acts on Cases Object

 

I am creating an object

Case abc = new Case ();

 

when I do system.debug ('The case created date is: ' + abc.CreatedDate);

 

In the output I see null for the created data, isn't this automatically generated how can it be null? its a not writable field

Best Answer chosen by Admin (Salesforce Developers) 
Baktash H.Baktash H.

If it is a before trigger the record is not inserted, thats why there is no ID or createdDate.

All Answers

VAHBVAHB

Same thing for Id,  doing abc.ID gets me null, but if the Case was created all of this should be automatically created

Baktash H.Baktash H.

If it is a before trigger the record is not inserted, thats why there is no ID or createdDate.

This was selected as the best answer