Sunday, March 18, 2012

Batch Upload of Data to related objects in Salesforce

I have been storming my mind for about a week to get an answer for performing batch upload of data into related objects for my Salesforce Environment . Once I found I felt shame on me asking " Why Don't you think in that way, wasting a week?"

Before looking into that first have a glance of "Automation of Data Loader From Command Line for Salesforce"

I was thinking how we can upload data into related objects (like Account and Opportunity) that are having Parent-Child Relationship and I found this simple solution.

All we know that if we want to load a child record to a parent we need the Salesforce ID created for that parent object.For example if we want to load an opportunity to an account first we need to give the Account IDof the account in the CSV file that we are uploading for the opportunity.

But it will be very complex if we want to do all four activities in one go i.e. 
i.Inserting an account
ii.Extracting the account id
iii.Mapping the Account id to the Opportunity data
iv.Inserting the Opportunity data

To do all this, we need to alter the mapping file only
In the mapping file used for inserting an opportunity we need to change the mapp for the Account ID field.

i.e the syntax should be like this.

AccountID=Account:\Extrnal_Id__c

where External_Id__c field is the External ID field in the Account object.

That's it we can run the batch process for data loading in related objects....

No comments:

Post a Comment