Find your content:

Search form

You are here

Setting SystemModstamp for OpportunityHistory

 
Share

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?


Attribution to: dublintech

Possible Suggestion/Solution #1

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 .


Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #2

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.


Attribution to: Jonathan Jenkins

Possible Suggestion/Solution #3

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


Attribution to: Jon Hazan
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5332

My Block Status

My Block Content