Four Stars

How to query salesforce using the output of the tmap?

Hello everyone, I am pretty new to Talend and I am trying to design a job which queries Salesforce using the output record of the tmap. For context, in the tmap, I am checking to see if the external ID field of the incoming record is null. If it is not null, I perform the upsert directly using tSalesforceOutput component to Contact object. If the External ID field is null, then I would like to query Salesforce using the incoming record's firstname and lastname combination, get the external Id,assign it to incoming record and perform an upsert operation. But I am not able to query the Salesforce using the fields of the record coming out of the tmap. I would very much appreciate any suggestions on how I should go about designing this job.

 

Thanks you.

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: How to query salesforce using the output of the tmap?

Of course you need to build your own where clause in tSalesforceInput using the global variables created by tFlowToIterate component.

TRF
3 REPLIES
Twelve Stars TRF
Twelve Stars

Re: How to query salesforce using the output of the tmap?

Hi,
As you want to query Salesforce for each record with a null value for the external ID, you need to pass the flow to a tFlowToIterate component, then use a tSalesforceInput to get the record for the corresponding lastname and firstname.
Check for tFlowToIterate documentation to understand how it works.
You need to understand you'll have as many distinct queries as records with null external ID. So, depending on the number of contacts and the probability to have no external ID, it should be better to query Salesforce once to retrieve all the existing contacts and join this result to the records from your tMap to retrieve the missing external ID.
In such a case consider to use bulk API for the query.
Hope this helps.

TRF
Four Stars

Re: How to query salesforce using the output of the tmap?

Hi TRF, thanks for the reply. I have set up the flow as per what you suggested. For now, I am trying with just  tFlowToIterate and TsaleforceInput to understand how everything works. The issue is, when I execute the job, tSalesforceInput is querying for all the contact records. How can can I limit it to query only for the records coming in from tFlowToIterate component?

Twelve Stars TRF
Twelve Stars

Re: How to query salesforce using the output of the tmap?

Of course you need to build your own where clause in tSalesforceInput using the global variables created by tFlowToIterate component.

TRF