function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rob CrossleyRob Crossley 

Apex Clone Method Does Not Preserve Read Only Timestamps

When I try and execute an Object Clone through Execute Anonymous, the inserted records do not preserve read only timestamps even though I have set the parameter preserveReadonlyTimestamps = TRUE.

I saw from this idea that this parameter does not work as described in the documentation unless Salesforce support temporarily enables it. Reference: https://success.sfdc.cdnetworks.com/apex/ideaView?id=08730000000a5TGAAY

Salesforce Support was not able to turn this on for me because they believed it was solved by the recent Winter 16 release which allows for profiles to be able to modify system audit fields. However, with this permission enabled, the clone method still does not work as described in the documentation.

Salesforce Support said that the way to have this feature enabled was to post a question on the Developer Discussion board, where a Salesforce moderator would see it and be able to enable it for my Org.

Can someone from Salesforce please reach out to assist with this functionality?
Best Answer chosen by Rob Crossley
Andy BoettcherAndy Boettcher
First off - Support is dead wrong - no one on the community can enable anything in your org.  They like to send you here when they cannot help.  Sorry to give you that bad news.  =(

The new Winter '16 functionality is only supported on a specified list of standard object, but all custom objects - the documentation is here:  http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_general_audit_fields_inactive_owners.htm.

Perhaps you're cloning an object not available to this new functionality?

All Answers

Andy BoettcherAndy Boettcher
First off - Support is dead wrong - no one on the community can enable anything in your org.  They like to send you here when they cannot help.  Sorry to give you that bad news.  =(

The new Winter '16 functionality is only supported on a specified list of standard object, but all custom objects - the documentation is here:  http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_general_audit_fields_inactive_owners.htm.

Perhaps you're cloning an object not available to this new functionality?
This was selected as the best answer
Rob CrossleyRob Crossley
Thanks for information. Based on the documentation you linked, the record I am trying to clone is unfortunately not covered with the new functionality as I am trying to update the Email Message object.

I will reach back out to support for assistance with this feature enablement. Do you know if the feature can be enabled on the Email Message object with the help of Salesforce Support?

I'm also curious if anyone else has had success in cloning the Email Message or solving this issue in general, as it seems like this would be a common request: The reason that I want to clone the email message is because that way I can clone it without the Email Headers. In this way, I can reduce my storage usage while at the same time preserving the original audit fields.
Kishore Singh AKishore Singh A
Hi,

Even i'm encountered with similar issue here. I'm doing a deepclone setting all the 3 parameters of clone method to true. In the logs i can see that system fields like ( createddate,createdby,lastmodifieddate ,lastmodifiedby) are overridden but it never shows up on detail page. Please let me now if this issue still persists in salesforce or if i'm missing anything.