function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
API USER 23API USER 23 

Salesforce SOAP API - Lookup relationship

Hello,

I am working on a mule flow that use a salesforce connector.

My question is that how to define a lookup relationship when using this connector when doing a bulk upsert (job list in Bulk Data Load Jobs)

The salesforce connector is using the https://test.salesforce.com/services/Soap/u/28.0 api.
My problem is that on my object I have a lookup and the upsert is working only if I use for this field the sfObjectId of the lookup object.

I would like to be able to use the externalId of my lookup object instead, but can't find the correct xml expression for it.


SvenSven
Hi,

You need to use upsert if you want to use the externalID and then your xml would look like this

<sfdc:upsert config-ref="mySalesforceConfig" type="Account" externalIdFieldName="InternalAccountCode">
    <sfdc:objects>
        <sfdc:object>
            <InternalAccountCode>A01596</InternalAccountCode>
            <Name>MuleSoft</Name>
            <BillingStreet>30 Maiden Lane</BillingStreet>
            <BillingCity>San Francisco</BillingCity>
            <BillingState>CA</BillingState>
            <BillingPostalCode>94108</BillingPostalCode>
            <BillingCountry>US</BillingCountry>
        </sfdc:object>
    </sfdc:objects>
</sfdc:upsert>
see http://mulesoft.github.io/salesforce-connector/mule/sfdc-config.html#upsert
Jameson TriplettJameson Triplett
If you are using datamapper to accomplish this, I created a GIST that will show the code to make this work To do relational fields you have to use the create-job and use Upsert as the operation
 
<batch:step name="Batch_Step1">
	<batch:commit size="1000" doc:name="Batch Commit">
		<data-mapper:transform
			config-ref="Pojo_To_List_Order_Line_Items__c__1Pojo_To_List_Order_Line_Items__c__2"
			doc:name="Pojo To List&lt;Order_Line_Items__c&gt;"/>
		<set-variable variableName="batchPayload" value="#[payload]" doc:name="Variable"/>
		<sfdc:create-job config-ref="SalesforceOrderConfig"
			operation="upsert" type="Order_Line_Items__c" doc:name="sfOrderJob"
			externalIdFieldName="EXT_OrderShipToLine_Number__c" />
		<set-variable variableName="job" value="#[payload]"
			doc:name="Job Variable" />
		<set-payload value="#[flowVars.batchPayload]" doc:name="Set Payload" />
		<logger level="INFO" message="Upsert Lines job id: #[flowVars.job.id]"
			doc:name="Lines JobId logger" />
		<logger message="SFDC Order Lines Batch Incoming Payload:  #[payload]"
			level="DEBUG" doc:name="Order Line Batch Logger" />
		<logger message="SFDC Order Lines Batch Starting:" level="INFO" doc:name="Order Line Batch Logger" />					
		<sfdc:create-batch config-ref="SalesforceOrderConfig" doc:name="sfOrderLineBatch" >  
	    		<sfdc:job-info ref="#[flowVars.job]" />
	    		<sfdc:objects ref="#[payload]"/>
		</sfdc:create-batch>

Inside Datamapper, you need to "Add Metadata Field" and create an Element with the __r object name, and then an attribute of that element with the lookup field name.
Pradeep Kumar L.GPradeep Kumar L.G
Hi @Jameson Triplett,

I am trying to do similar operation using DataWave, Would it be possible to share more info on how to use Parent__r: Parent_External_ID__c to while loading child records..

Thanks
Pradeep