Saturday, March 28, 2015

System / Audit Fields in Salesforce

Every system or application has system fields for auditing. In Salesforce these fields are referred as "Created Date, Last Modified Date, Created By, Last Modified By".

Usually System/Audit fields are READ ONLY and automatically populate by Salesforce.com. But there is a time when you need to import data into these fields.


Use Case

A company has a database to store Invoices and now they have decided to use Salesforce and migrate all Invoices into Salesforce objects. They want to migrate system / audit fields (Created Date, Last Modified Date, Created By, Last Modified By) as well along with other data.


What Does it Do?

Allows you to set Created Date, Created By, Last Modified Date, Last Modified By
Useful for migrating data from external systems and preserving history
By default, System / Audit fields are Read Only


How Do you Get it?

By default, this feature is not enabled in Salesforce.com organisations. You need to log a case to Salesforce.com customer support to enable this feature.


Considerations

  • Audit fields can only work on INSERT / CREATE of new records.
  • Generally READ ONLY for existing records. Audit fields do not work on UPDATE / MODIFY of records.
  • Only accessible through API
  • Backward compatible with all SOAP-based API's
Audit fields will only be enabled for following objects (as of Spring ‘15)
  • Lead
  • Account
  • Contact
  • Opportunity
  • Case
  • Tasks and Events
  • All Custom Objects
Other Objects
  • Attachments
  • CampaignMember
  • CaseComment
  • FeedComment
  • FeedItem
  • Idea
  • IdeaComment
  • Vote 
  • Contracts
Additionally, Audit fields from the Lead object related to conversion can also be defined on INSERT / CREATE:
  • ConvertedDate
  • ConvertedAccountId
  • ConvertedContactId
  • ConvertedOpportunityId

Useful Resources