Four Stars

Where Clause in SOQL

Hi,

I am new to Talend. I would like to query the Account object by using where clause. I would like to pass the value from webservice request to this variable in where clause. Please help for the steps to acheive this.

Thanks,

Rajesh

  • Data Integration
  • ESB
3 REPLIES
Nine Stars TRF
Nine Stars

Re: Where Clause in SOQL

Supposing you know how to extract the request body using tExtractXMLField component, you can set a global variable with the value of the desired field (using tSetGlobalVar or tJavaXxxx) then reuse this variable as the "Condition" in the tSalesforceInput with the following syntax (assume the variable is called AccId__c as for the Account field):

"AccId__c = '" + (String)globalMap.get("AccId__c") + "'"

Assuming the datatype is Text on Salesforce side, this will generate the desired condition at runtime with the appropriate syntax and value.

Hope this helps. 


TRF
Four Stars

Re: Where Clause in SOQL

Hi TRF,

 

Thanks for your reply. It seems textractxml used to extract fields from stream. I am expecting webservice request and if i use tmapxml then i can extract the fields directly. Still i didn't the clue about how we can declare the variable on a job ( Purely this should go in the scope of job) and how to set it from incoming webservice request. Use case is, i have account number is coming in webservice request xml, and i need to query the account id from account object which need to pass on Asset object to link the account while upserting it. I am not sure how to achieve this.

Thanks,

Rajesh 

Nine Stars TRF
Nine Stars

Re: Where Clause in SOQL

The way how you get the message, doesn't matter. As soon as you get the expected field, you can set the global variable using tSetGlobalVar or a tJavaXxxx component. In this case the syntax is as simple as:

globalMap.put(row1.yourField);

For your use case, you can now have a tSalesforceInput to get the Account Id you'll use when upserting the Asset record.

Also, if the field associated to what you called Account Number is declare as an external id, you don't have to get the Account Id before to upsert the Asset, you can go to the advanced setting of the tSalesforceOutput component and manage the relationship using this external Id.

Does this helps?

 


TRF