Handelbar expression

Hello Guys,

we have below expression as below,

{{#compare discount_applications.0.title "==" "loop-discount"}}NonTaxable_loop-discount{{else}}{{#compare shipping_address.country_code "!=" "AU"}}{{#compare current_total_price "==" "0.00"}}{{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}{{else}}{{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}{{/compare}}{{else}}{{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}{{/compare}}{{/compare}}

We mapped the expression for 'Items: Tax Code (InternalId)' in Celigo. The issue is that it works only for the first line item in the sales order in NetSuite, and not for all items. Could you please help us figure out what needs to be updated in the existing expression?

.

Hi,

The reason it only fills the first line is that the expression does not start in the line item array so it seemsdiscount_applications, shipping_address, current_total_price are all header-level. In Celigo, if your expression doesn’t reference a line array with [*], it’s evaluated once and applied to the first mapped line only.

To fix this: anchor the expression to the line scope by referencing a line field with [*] (any stable line key works, e.g., line_items[*].id). Then keep your existing compares inside. This forces Celigo to evaluate the block for every line.

{{#if line_items[*].id}}
  {{#compare discount_applications.0.title "==" "loop-discount"}}
    NonTaxable_loop-discount
  {{else}}
    {{#compare shipping_address.country_code "!=" "AU"}}
      {{#compare current_total_price "==" "0.00"}}
        {{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}
      {{else}}
        {{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}
      {{/compare}}
    {{else}}
      {{#if shipping_address.country_code}}{{shipping_address.country_code}}{{else}}US{{/if}}
    {{/compare}}
  {{/compare}}
{{/if}}

Why this works:

  • line_items[*].id switches evaluation to “per-line” mode.

  • The inner #compare logic still uses header fields, but it now runs once for each line, so the mapped Items: Tax Code (InternalId) gets a value on all lines.

Example without the if:

Example with the if:

2 Likes

Hello Nuri,

Excellent, it worked. Thank you so much!

2 Likes

Good to hear, kindly mark my reply as solved so this thread has a solution.

1 Like