SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Salesforce (Actions) Custom Object V2 Sync Failure: InvalidBatch Error Due to Non-External ID Lookups

Issue

When syncing data to Salesforce (Actions) using Segment, the Custom Object V2 mapping works in the Mapping Tester but fails during regular production syncs. 

The error InvalidBatch: Field name not found appears when attempting to use a non-External ID field for relationship lookup (xxx__r.xxx__c) in the Bulk Data Load Jobs.

For example:

 

Product

Twilio Segment

 

Environment

Segment Console

 

Cause

This issue happens because Segment uses two different APIs to send data to Salesforce during testing versus regular production syncs.

When you test using the Mapping Tester, Segment sends data using Salesforce's streaming REST API, which easily handles relationship lookups against non-text fields. 

However, for regular production syncs, Segment uses Salesforce's high-volume Bulk API 2.0 to ensure efficiency. This bulk method has a much stricter rule: any field used to look up a relationship (xxx__r.xxx__c) must be a standard Text field marked as an External ID

If you are using a field that is not marked as an External ID, the production sync will fail to recognize it.

 

Resolution

To fix this, you must store the ID in a standard Text field that is marked as an External ID in Salesforce. Follow these steps:

  1. Log into your Salesforce account and navigate to the Object Manager.

  2. Select the target object and create a new custom field with the data type Text.

  3. In the field settings, check the boxes to mark this field as an External ID and Unique.

  4. Save the field and ensure your system populates this new Text field with your unique IDs moving forward.

  5. Log into the Segment workspace, navigate to your Salesforce destination mappings, and update the mapping to point to your newly created Text field.

 

Additional Information 

You can find more details here:

  • Salesforce Docs: This explains that for Bulk API, the field in the related object must be an External ID.
  • Salesforce forum: Note that formula fields cannot be marked as External IDs, which is the requirement for Bulk relationship lookups.

 

Have more questions? Submit a request
Powered by Zendesk