Importing Accounts with Complex Hierarchies
Mar 1, 2005Salesforce.com supports importing of Accounts through its import wizard. During this process it can associate accounts in a hierarchical relationship by matching a parent account name in the import file to an existing account. However, frequently data is linked in other systems using another relationship e.g. an id and parent id field. In this situation, there is no easy way to make the import wizards set up the hierarchy correctly.
A solution is to run the import without mapping the parent account name and then updating the records in Salesforce after the import. In order for the update to occur, you must import the extra fields which link the accounts. These values can be stored in standard fields such as ACCOUNT_NUMBER and SIC_CODE or into custom fields.
Once the data is imported, the update can be performed. One quick and easy way to do this is using Excel and the Sforce connector for Excel. The steps are:
1/ Run an Account query using the connector to retrieve all accounts
2/ Use the Excel VLOOKUP function to populate the parent account according to your preference
3/ Update the Accounts back to Salesforce using the connector update
The hardest part of making this work is understanding the VLOOKUP function. The documentation in Excel for this function is fairly clear but here is an example
=IF(ISERROR(VLOOKUP(D5,A:B,2,FALSE)),"",VLOOKUP(D5,A:B,2,FALSE))
The core of this function is the VLOOKUP(D5,A:B,2,FALSE) expression. This means find the value in D5 in the A column and, if a match is found, return the value in B5. As you paste this function into other rows, the relative references will update i.e. D5 becomes E5
Sometimes this function will not return a match and then returns an error which breaks the Salesforce update. The solution is to enclose the VLOOKUP with an ISERROR check so that a non-match will return the empty string and this then updates the Salesforce field correctly.
This is a fairly simple example where the hierarchy is controlled by separate ids but it can be extended to implement any relationship. Happy importing…
Steve Buikhuizen | Sales Engineer | Salesforce.com Asia Pacific

0 Comments