Resolving Liquid Syntax Error for CustomVariable in Workflow Callout Task
Issue: When integrating Zuora with NetSuite, users may encounter a Liquid syntax error stating "Liquid error: Data Error: Undefined variable MappedNetSuiteID" in the NetSuite Callout task of a Zuora workflow. The variable MappedNetSuiteID could be any custom variable you are attempting to pass in a preceding javascript task.
Cause: This error occurs when the Liquid template in the callout body attempts to access a variable that isn't directly available in the expected data structure. The issue often arises due to differences in how data is passed between tasks in the workflow.
Solution: To resolve this issue, we implemented a solution using Liquid syntax directly in the Callout task:
In the Callout task, update the Liquid syntax in the callout body to:
{% assign paymentMethodMapping = '{"ACH":7,"Check":2,"CreditCard":8,"WireTransfer":10,"CreditCardReferenceTransaction":12,"CC Reference Transaction":12,"BankTransfer":13,"Other":14}' | parse_json %} { "custbodyzuo_pay_meth_upd": {{paymentMethodMapping[Data.PaymentMethod.Type] | default: 0}} }
Explanation:
We define a
paymentMethodMapping
object directly in the Liquid template using a JSON string and theparse_json
filter. This mapping correlates payment method types to their corresponding NetSuite IDs.The
custbodyzuo_pay_meth_upd
field is then populated by looking up the NetSuite ID based on the payment method type (Data.PaymentMethod.Type
).The
default: 0
ensures that if no matching payment method is found, it defaults to 0 instead of causing an error.
Benefits of this approach:
Simplicity: It eliminates the need for a separate JavaScript task, simplifying the workflow.
Direct mapping: The payment method to NetSuite ID mapping is defined directly where it's used, making it easier to update and maintain.
Error prevention: The use of
default: 0
ensures that the workflow doesn't fail if an unknown payment method type is encountered.
Additional Notes:
Ensure that
Data.PaymentMethod.Type
is correctly populated in your workflow before this callout task.This solution allows for dynamic mapping of payment method types to NetSuite IDs, making it flexible for various payment methods.
Always test the workflow after implementing these changes to ensure it works as expected with different payment method types.
If you need to update the mapping, you can modify the JSON string directly in this Liquid template.
By implementing this Liquid syntax in your Callout task, you should resolve the "Undefined variable {{CustomVariable}}" error and successfully pass the correct information.