+ Start a Discussion

Salesforce SOAP API - Lookup relationship


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.


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">
            <BillingStreet>30 Maiden Lane</BillingStreet>
            <BillingCity>San Francisco</BillingCity>
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">
			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]"/>

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..