Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have some logic where I have to send emails about Opportunities that have certain OpportunityHistory objects at certain date times.

I would like to test this but it means I need to be able to explicitly set SystemModstamp in my test. When I try to do this, I get:

save error: Field is not writeable: OpportunityHistory.SystemModstamp

Is there anyway around this?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

SystemModstamp is an Audit field and is not set-able even if you get Salesforce to allow you to access Audit fields.

See here for more info:

http://www.salesforce.com/us/developer/docs/api/Content/system_fields.htm

share|improve this answer
add comment

The systemModified time stamps are not allowed to overwrite .Those are not writable field .Testing may require with reducing the value for testing for small interval.

Example if your test scenario is with 30 days old change in code for 2 days old date and test it and after test update again in code for 30 days old .

share|improve this answer
add comment

What is the logic that references OpportunityHistory?

OpportunityHistory is read only and is system generated based on criteria so you cannot create it in tests nor can you update an opportunity in your tests then reference the history as the records are only created upon a database commit.

I've ran into this issue before using ActivityHistory and had to query tasks instead of history to make it work - this may be more difficult with opportunity history.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.