5

I need to create a SObject in a unit test with the SystemModstamp set. I've been using Opportunities in my unit test, but I am not tied to that specific SObject. I also am not tied down to SystemModstamp (though that is what my app used in production). I really just need to be able to modify a DateTime field on a SObject. Ideally though, I would be able to set the SystemModstamp or cause it to be set. I tried inserting the newly created Opportunity, but it looks like that insert doesn't populate the SystemModstamp.

2 Answers 2

2

The SystemModStamp will always be set. If you requery the object in your test class it should get you the SystemModStamp:

Account a = new Account();
a.Name = 'name';
insert a;

system.debug(a.systemModStamp);
system.debug([select Id, SystemModStamp From Account Where Id = :a.Id]);

returned:

|DEBUG|null
|DEBUG|(Account:{SystemModstamp=2014-04-03 19:08:12, Id=001c000000Y36ucAAB})
0

this is one of the audit fields which salesforce managed internally. Yes, it is possible to update it but you have to open a case with Salesforce and they will allow you do that at your own risk.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .