External IDs and Global Keys (Managed Package)

For the managed package runtime, most objects that are being deployed have a field or set of fields that are used to find unique records like an External Id in Salesforce. For many objects, the Global Key field is used. If a deployment finds one object that matches the global key, it overwrites that object during deploy.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

If the deployment finds more than one object, it causes this error:

Deploy Error >> Product2/02d3feaf-a390-2f57-a08c-2bfc3f9b7333 --- iPhone --- 
Duplicate Results found for Product2 WHERE 
vlocity_cmt__GlobalKey__c=02d3feaf-a390-2f57-a08c-2bfc3f9b7333 - Related Ids: 
01t1I000001ON3qQAG,01t1I000001ON3xQAG

This error means that duplicates have been created in the org and the data must be cleaned up.

While there are protections against missing or duplicate global keys the logic is often in triggers which may have at points been switched off, and sometimes applies to data that may have existed before the Vlocity Package was installed.

This command starts a set of batch jobs to add global keys to any objects that are missing them:

vlocity -propertyfile <propertyfile> -job <job> runJavaScript -js cleanData.js

This Node.js script adds global keys to all SObjects that are missing them, and deletes stale data records.

Note
Note If you’re deploying data between orgs, and both orgs are missing global keys but have data that you don’t want to duplicate, use a different strategy to produce global keys that match.