Else If in Dataweave 2.0
I Am Trying to Write Else If Statement in My Data Weave but Getting the Error Expression Missing "" Pbsi__Tax_Code__C: If((Payload. Order...
I am trying to write else if statement in my Data weave but getting the error expression missing ""
PBSI__Tax_Code__c : if((payload.order.customer."billing-address"."country-code" =="NL") "${sf_taxcode}" else if(payload.order.customer."billing-address"."country-code" =="DE") "${sf_deTaxcode}"),
2 Answers
The expression is missing the else of the last if sentence. It is mandatory to have an else.
As a simplified example:
{
PBSI__Tax_Code__c:
if(country_code =="NL") "something" else if(country_code =="DE") "something" else "something else"
}
Also note that it in DataWeave configuration properties are accessed with the p() function.
%dw 2.0
output application/json
---
{
PBSI__Tax_Code__c :
if(payload.order.customer."billing-address"."country-code" =="NL") p('sf_taxcode')
else if(payload.order.customer."billing-address"."country-code" =="DE") p('sf_deTaxcode')
else "as default"
}