Loading

Use an 'External ID' to set the values for audit fields

Udgivelsesdato: Dec 26, 2023
Beskrivelse

If your organization has enabled the ability to set 'audit' field values for imported records, you can use an External ID field as the matching value when you insert new records in Data Loader. 


In order to use the External ID field to insert audit fields:

  • You need to use the Upsert option in the Data Loader when you create the new records
  • The CSV file for the records to be created should include a column for the External ID field that is populated with a unique value. 
Løsning

To get started, create an External ID field on the desired object: 

  1. Navigate to Setup.
  2. Navigate to Fields under the desired object
    • In Salesforce Classic: 
      • For Standard objects, click Customize | Object Name | Fields
      • For Custom Objects, click Create | Objects | Object Name | Scroll to Custom Fields & Relationships
    • In the Lightning Experience:
      • Click the Object Manager tab | Object Name | Fields & Relationships
  3. Click New
  4. Select Text
  5. Click Next
  6. Add the name of the field and label
  7. Select Unique: "Do not allow duplicate values." Then select "Treat "ABC" and "abc" as different values (case sensitive)"
  8. Select External ID: "Set this field as the unique record identifier from an external system."
  9. Click Next
  10. Choose the Profiles that should be able to see the field
  11. Click Next
  12. Choose the page layout where it can be viewed
  13. Click Save

Once you've created the External ID field and populated the CSV file with a unique value for each record, you can use the Data Loader to insert the records and set the Audit fields. 

 

Create new records and set CreatedByID and/or LastModifiedByID using an 'External ID'

  1. Log in to Data Loader.
  2. Click Upsert. 
  3. Choose the desired object and file to use, then click Next.
  4. From the dropdown list, select the External ID field to use for matching.
  5. Click Next.
  6. Select either Existing Mapping or Create or Edit a Map (or select 'Auto-Match Fields to Columns' and edit or manually map fields if needed). 
    Note: Most importantly, ensure that you've mapped your Audit System Fields (CreatedDate, CreatedById, LastModifiedDate, LastModifiedById).
  7. Click Next.
  8. Click Finish.
  9. Click Yes on the pop-up message.
Note: If the CSV file contains any existing records, the upsert fails with an error. Audit fields can only be created, and so the CSV file must only contain new records. Error: 

Unable to create/update fields: CreatedDate. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

See also: 
Vidensartikelnummer

000383278

 
Indlæser
Salesforce Help | Article