How to use external Id to Upsert data in salesforce using Talend
Please find below links for the installation and introduction about Talend. https://blogs.absyz.com/2018/10/16/introduction-to-talend-integration-tool/ https://blogs.absyz.com/2018/10/17/how-to-export-data-from-salesforce-using-talend/
What is an external Id?
External Id is a very interesting feature given by Salesforce. It is very helpful when we are importing data from external system without duplicates. It references an ID (record Identifier) from external system. Only 3 types of fields are allowed to be used as an external Id.
Benefits of using External Id field:
- We can directly upsert data using external field. (Upsert is combination of insert and update, if the record already exists in the system it will update else it will insert a new record)
- We can create parent child record without querying for parent record Id
- We can use external Id fields in SOQL
How to make a field as an external Id?
While creating a field you will probably see the option to make a field external Id.
How to upsert data with external Id in Talend?
Let see how we can upsert contacts by populating account lookup value using external id in talend.
I have created external id fields in contact and account.
External id field in contact: External_Number__c
External id field in Account: Account_Number_external__c
1.Create a new job in talend
2. Drag and drop tFileOutputDelimited from palette to workspace. Choose the file name and separator.
3. Drop and drop tMap from pallet to workspace. Add an output table and add columns in it. Make sure you are adding the API names from salesforce.
4. Drag & drop tSalesforceOutput from pallet. Give your credential like username, password & security token. Select module as contact as we are doing the dml on contacts. Select output action as upsert, then you will find an option to select external key choose external key from the list.
5. Go to advanced settings you will see Relationship mapping for Upsert
Description for each column:
Column name of talend schema: select the column name where parent external key was copied.
Lookup field Name: API name of account lookup field from contact objects
Lookup relationship field name: relationship name for standard fields it is same lookup field. For custom fields append __r .
Module name: The parent object name
External id name: external id field from parent object. Here it is from account.
6. Save the changes and run the job.
The overall job looks like this :
Results in Salesforce: