Skip to Content

Process target records conditionally in Jitterbit Design Studio

Use case

Incoming record set with multiple records, and a subset of records should be processed. The record set payload may be as a result of a query, but additional filtering is needed.

Example

attachment

The operation 0101 Query SF Accounts performs a query of SFDC Accounts, then creates customers in NetSuite, which in turn updates the SFDC Account. An error process updates Accounts on an error condition associated with the PDF Template type.

The Accounts records have to be evaluated on a record-by-record basis, and depending on the value of a field, processed in the main success scenario, or passed to error processing.

attachment

Using a condition in a transformation allows you to evaluate each record. If the condition evaluates to true, as in this case, the record is written to the temp file. If false, it is skipped.

Specifically, values are passed to RunScript(), which will return a string of "Error" if the lookup fails. So if the local variable "result" equals "Error", then the failure operation is run, the local variable "cond" is set to false, and the record is skipped.

// Skip records where the pdf template lookup is incorrect
result = RunScript("<TAG>Scripts/PDF Template Lookup</TAG>",
root$transaction.response$body$queryResponse$result$records.Account$CccccccAaaaaaaa_Entity__c$,
root$transaction.response$body$queryResponse$result$records.Account$CurrencyIsoCode$,
root$transaction.response$body$queryResponse$result$records.Account$Payment_Method__c$,
root$transaction.response$body$queryResponse$result$records.Account$BillingCountry$);
// Set Sync Error Code to 3 if cannot find a match. Determine if returned an "Error" or not.
WriteToOperationLog("Template Lookup: "+result);
If(result=="Error",
$Id = root$transaction.response$body$queryResponse$result$records.Account$Id$;
RunOperation("<TAG>Operations/01 SF->NS Create Customer/0199 Update Accounts PDF Template Error</TAG>");
 cond=false, cond=true);
cond

For the sake of completeness of the example, this is the RunScript() call. Of interest is the use of ArgumentList(), which allows this script to behave as a reusable function:

ArgumentList(Sub,Cur,Pay,Cnt);
Case(
Sub=='CccccccAaaaaaa AU' && Cur=='AUD' && (Pay =='Check'||Pay =='Wire/EFT/BACS'||Pay == 'PayPal'),2,
Sub=='CccccccAaaaaaa AU' && Cur=='AUD' && (Pay =='Credit Card'||Pay == 'Bank Draft'||Pay == 'Direct Debit'),3,
Sub=='CccccccAaaaaaa Brands UK' && (Cur=='USD'||Cur=='EUR'||Cur=='GBP'),26,
Sub=='CccccccAaaaaaa YY LTDA' && Cur=='BRL',17,
Sub=='CccccccAaaaaaa Corporation' && Cur=='USD' && (Pay =='Check'||Pay =='Wire/EFT/BACS' ||Pay == 'PayPal') && Cnt != 'CccccccAaaaaaa',4,
Sub=='CccccccAaaaaaa Corporation' && Cur=='USD' && Cnt == 'CccccccAaaaaaa',5,
Sub=='CccccccAaaaaaa Corporation' && Cur=='USD' && (Pay =='Credit Card'||Pay == 'Bank Draft'||Pay == 'Direct Debit'),1,
Sub=='CccccccAaaaaaa Hong Kong' && Cur=='USD',19,
Sub=='CccccccAaaaaaa UK' && Cur=='GBP' && (Pay =='Check'||Pay =='Wire/EFT/BACS' ||Pay == 'PayPal'),6,
Sub=='CccccccAaaaaaa UK' && Cur=='EUR' && (Pay =='Credit Card'||Pay == 'Bank Draft'||Pay == 'Direct Debit'),24,
Sub=='CccccccAaaaaaa UK' && Cur=='GBP' && (Pay =='Credit Card'||Pay == 'Bank Draft'||Pay == 'Direct Debit'),7,
Sub=='CccccccAaaaaaa UK' && Cur=='EUR' && (Pay =='Check'||Pay =='Wire/EFT/BACS' ||Pay == 'PayPal'),8,
Sub=='CccccccAaaaaaa Washington LLC' && Cur=='USD' && (Pay =='Credit Card'||Pay == 'Bank Draft'||Pay == 'Direct Debit'),9,
Sub=='CccccccAaaaaaa Washington LLC' && Cur=='USD' && (Pay =='Check'||Pay =='Wire/EFT/BACS' ||Pay == 'PayPal'),10,
true,"Error"
)

Also see: Updating multiple targets from a single source record