Salesforce supports cascading update and inserts function by using reference key. In Talend, we can perform the cascading UPSERT function by using tSalesforceOutputBulkExec or tSalesforceOutput components. The benefit of using this function is to reduce the API call from Talend to Salesforce. Imagine the number of calls to make if there are millions of record for data migration.In order for us to use this function, we need to have an external Id.
For example, when we upset a Contact record and want it assigned to an Account record, all we will need to do is pass in the Account External Id. This will help to find the related Account record and assign it back to the Contact via the lookup field.
Now, let’s try to upset some sample Contact records into Salesforce.
As you can see, there is a column called as accountId which is the Account’s external Id. Later in the Talend process, we will use this value to perform cascading upsert function.
Before the following process, the Account.csv has already been preloaded. Below is the sample upsert job in Talend.
Below is the mapping result:
How to Configure:
In the tSalesforceOutputBulkExec component, select the ‘Advanced Setting’. Now focus on the ‘Relationship mapping for upsert’ column.
In the ‘Column name of Talend Schema’, select the external id value from the map. In our case, the AccountId from the contact profile(from the mapping) will be the external id. Secondly, the ‘Lookup field name’ is the lookup field between the Contact and Account objects in the Salesforce. Hence, it will be the Account field in Contact object. Do not be confused by the ‘External id name’ as it indicates the external id in Account object, not the Contact object. Below is the complete configuration:
We are finally done. Check out the results!