Integration · Salesforce

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.

They are

  • Email
  • Text
  • Number

Benefits of using External Id field:

  1. 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)
  2. We can create parent child record without querying for parent record Id
  3. 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.

externalimage

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                                   

 job_Creation

2. Drag and drop tFileOutputDelimited from palette to workspace. Choose the file name and separator.

fileoutputdelimited

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.     

Tmap

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.         

SFOutput

5. Go to advanced settings you will see Relationship mapping for Upsert

lookupUpsert

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 : 


overallJob

 Results in Salesforce:     


result_sf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s