Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

10
Name of Solution: Upsert SFDC Targets and Overview on SFDC Lookups Business Requirement: Insert/Update a Contact in Salesforce using a Lookup on Account object and adding a filter condition in the Account Lookup, without using the Filter/Router/Update Strategy Transformations Description: Generally for an upsert process, we do a lookup on the target and then have a router to see if it exists in the target or not. If the record does not exist in the target, then it is inserted, else it is updated using an Update Strategy Transformation. This mapping demonstrates: 1. An alternative method to upsert data in Salesforce target without using Router/Update Strategy Transformations. 2. The use of Salesforce Lookup and adding a filter condition in the Lookup. 3. To establish – de-establish relationship between two connected Salesforce objects using Expression Transformation Pre-Requisites: To Create a Salesforce developer account in Force.com: Click the below link to create a new salesforce.com development org http://www.developerforce.com/events/regular/registration.php Security Token: A security token is an automatically generated key that you must add to the end of your password in order to log in to Salesforce via the API. For example, if your password is mypassword, and your security token is XXXXXXXXXX, then you must enter mypasswordXXXXXXXXXX to log in. To Reset your Security Token: 1. At the top of any Salesforce page, click the down arrow next to your name. From the menu under your name, select Setup or My Settings—whichever one appears. 2. From the left pane, select one of the following: If you clicked Setup, select My Personal Information | Reset My Security Token. If you clicked My Settings, select Personal | Reset My Security Token. 3. Click the Reset Security Token button. The new security token is sent via email to the email address on your Salesforce user record.

description

dd

Transcript of Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

Page 1: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

Name of Solution:

Upsert SFDC Targets and Overview on SFDC Lookups

Business Requirement:

Insert/Update a Contact in Salesforce using a Lookup on Account object and adding a filter condition in

the Account Lookup, without using the Filter/Router/Update Strategy Transformations

Description:

Generally for an upsert process, we do a lookup on the target and then have a router to see if it exists in

the target or not. If the record does not exist in the target, then it is inserted, else it is updated using an

Update Strategy Transformation.

This mapping demonstrates:

1. An alternative method to upsert data in Salesforce target without using Router/Update Strategy

Transformations.

2. The use of Salesforce Lookup and adding a filter condition in the Lookup.

3. To establish – de-establish relationship between two connected Salesforce objects using

Expression Transformation

Pre-Requisites:

To Create a Salesforce developer account in Force.com:

Click the below link to create a new salesforce.com development org

http://www.developerforce.com/events/regular/registration.php

Security Token:

A security token is an automatically generated key that you must add to the end of your

password in order to log in to Salesforce via the API.

For example, if your password is mypassword, and your security token is XXXXXXXXXX, then you

must enter mypasswordXXXXXXXXXX to log in.

To Reset your Security Token:

1. At the top of any Salesforce page, click the down arrow next to your name. From the

menu under your name, select Setup or My Settings—whichever one appears.

2. From the left pane, select one of the following:

If you clicked Setup, select My Personal Information | Reset My Security

Token.

If you clicked My Settings, select Personal | Reset My Security Token.

3. Click the Reset Security Token button. The new security token is sent via email to the

email address on your Salesforce user record.

Page 2: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

The standard objects, Account and Contact are used in the mapping. Please create external IDs,

as Account_ID__c and Contact_ID__c for the respective objects.

Steps to Create Salesforce Lookup Transformation:

1. Go to Transformation Tab and select the Salesforce Lookup Transformation. Provide an

appropriate name.

2. Provide the username, password appended with security token to connect to Force.com. The

default service URL may change depending on the Dev/Test environment salesforce sandbox.

3. Click Connect. The Designer displays a list of objects available to the Salesforce user.

Page 3: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

4. Select the Account object that needs to be imported and click on Ok.

5. Select the relationships to include, and click Ok. If there are no conflicts, the Designer creates a

Salesforce Lookup transformation based on the selected object and related objects. If there are

conflicts, resolve the conflicts.

Page 4: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

Steps to Create Salesforce Target Definition:

1. Go to the Target Designer tab in your designer. Click the Targets tab and click the “Import from

Salesforce.com” as shown below:

Page 5: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

2. Provide the username, password appended with security token to connect to Force.com. The

default service URL may change depending on the Dev/Test environment salesforce sandbox.

3. Click Connect. The Designer displays a list of objects available to the Salesforce user.

4. Select the Contact object that is used as the target and click on Ok.

Page 6: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

5. Select the relationships to include, and click Ok. If there are no conflicts, the Designer creates a

Salesforce Target based on the selected object and related objects. If there are conflicts, resolve

the conflicts.

Steps to Create the Mapping:

1. Create a new mapping m_ SFDC_Contact.

2. Create a source definition for the source file provided.

3. Create an expression transformation after the Source Qualifier Transformation. Create a new

Output Port, Condition which has the below expression:

'Type = ' || CHR(39) || 'Customer - Direct' || CHR(39) || ' AND Rating = ' || CHR(39) || 'Hot' || CHR(39)

Page 7: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

Here, CHR(39) is the ASCII value of Single Quote(‘). The Condition port will be sent as Input to

the LKP_FILTER Port in the next Salesforce Lookup Transformation.

4. Get the Salesforce Account Lookup Transformation that was created earlier. The required

output ports from the earlier Expression Transformation are mapped to the SFDC Lookup

Transformation as Pass-through Ports.

5. The Account_ID__c is the external_ID in the Account object. Please make sure that it is linked

from the previous transformation.

6. The Condition port from the previous Expression Transformation is mapped to the LKP_FILTER

port.

7. The ID is taken as Output from the Salesforce Account Lookup Transformation.

8. The SOQL SELECT statement for each row that passes through the transformation has the

following format:

SELECT ID FROM ACCOUNT WHERE AccountID__c = ‘<value of Account_ID>’ AND TYPE = 'Customer - Direct' AND Rating = 'Hot'

Page 8: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

9. Map the Output ports from the Salesforce Lookup Transformation to the Expression

Transformation, exp_Get_RecordID_Account. Include the below expression in the Output port

for RecordID from Account Lookup:

IIF(ISNULL(I_RecordId_Account),' ',I_RecordId_Account)

The above condition de-establishes the relationship between the Account and Contact objects

when a record from the source does not have corresponding Account. For example, if the

Account_ID from source file does not exist in the Account object, then the output port, Id from

the Account Lookup Transformation will be NULL. So in this scenario, if we directly pass the Id

with NULL value from the Account Lookup to the Contact object’s AccountId field, then the

previous relationship between Account – Contact objects will not be over-ridden. So we have

added the above condition in the expression transformation which will de-establish the

Account-Contact relationship.

Page 9: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

10. Map the Output port O_RecordID_Account from the expression to the AccountID port in the

SFDC Target. Please note that the AccountID in the target is of Lookup datatype that looks up

from the Account object. So here, we are passing the RecordID to this field, which will display

the corresponding Account Name.

11. Below is the screenshot of the complete mapping:

Steps to Create the Session:

1. Go to the Task Developer in Workflow Manager and create a new Session task for the mapping

created.

Page 10: Userguide Upsert SalesforceTargets anddd Overview on Saleseforce Lookups

2. In the Mapping tab, click on Targets and select the appropriate Salesforce connection string.

3. Select the check boxes for “Treat Insert as Upsert” and “Treat Update as Upsert“.

4. Select the check boxes for “Use SFDC Error File” and “Use SFDC Success File” and mention the

SFDC Success File Directory as “$PMTargetFileDir”.

5. Create the workflow and include the above created session. Select the Integration Service and

run the workflow.