---
sourceDocument: Brazil Sales Customer Relationship Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/order-management

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Sales Customer Relationship Management

ft:clusterId :

    - omgmt

bundleId :

    - omgmt

workflow :

    - Customer and Industry


---

# ServiceNow Quote Experience Integrations - Handlebars syntax

# ServiceNow Quote Experience Integrations - Handlebars syntax {#ariaid-title1}

Release version: Brazil  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 5 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of ServiceNow Quote Experience Integrations - Handlebars syntax

This document explains how ServiceNow administrators can use the Handlebars templating language to build integration transformation templates within the Quote Experience Integrations.
Handlebars enables dynamic content generation by inserting variables, functions, and conditional logic into templates, enhancing the flexibility and maintainability of integration data transformations.
Show full answer Show less  

## Key Features

* **Handlebars Expressions:** Use double curly braces `{{ }}` to insert variables or properties, such as `{{user.name}}`.
* **Conditional Helpers:** Control template output based on data conditions:
  * `#if` renders content if the condition is true.
  * `#unless` renders content if the condition is false.
* **Iteration Helpers:** Loop through arrays or change scope:
  * `#each` iterates over lists to render content per item.
  * `#with` changes the scope to simplify access to nested objects.
* **Whitespace Control (\~):** The tilde character trims extra spaces or line breaks for cleaner output.
* **Custom Helpers:**
  * `zeroIfMissing` ensures numerical values default to zero if missing, preventing errors.
  * `lgkFilter` filters collections based on numeric or text conditions, replacing standard iteration and conditional blocks for more precise data selection.
* **Parent Context Reference (@ symbol):** Retrieves values from outer or parent data contexts to avoid scope confusion.
* **Conditional Assignment and Dynamic Referencing:** Enables dynamic field values based on data presence, using nested Handlebars expressions within conditionals.
* **Concatenation with Conditionals:** Supports combining multiple fields with conditional punctuation, ensuring clean and accurate formatting of complex data like addresses.

## What ServiceNow Customers Can Expect

By mastering these Handlebars elements, ServiceNow administrators can:

* Create dynamic, flexible integration templates that handle complex data structures and conditions.
* Prevent errors from missing data with default value helpers.
* Filter and process only relevant data items efficiently using custom helpers.
* Generate clean, compact JSON or HTML output through whitespace control.
* Use parent context referencing for accurate data retrieval across nested scopes.
* Build maintainable templates that support conditional logic and dynamic content assembly.

This enables effective integration between ServiceNow CPQ and external systems, improving data accuracy and automation in quote processing workflows.

## Practical Application Tips

* Use `#if` and `#unless` to control when data renders based on availability or status.
* Apply `#each` or `lgkFilter` to loop through or filter line items dynamically.
* Incorporate whitespace control to avoid unwanted gaps or line breaks in output.
* Leverage custom helpers like `zeroIfMissing` to ensure numeric fields are always valid.
* Use `@` to reference data from parent scopes, especially in nested templates.
* Combine conditional blocks to build complex concatenations, such as full addresses with optional components.  
You can use the Handlebars templating language when you build an integration transformation template.
Handlebars is a lightweight templating language used to generate dynamic content. Administrators building integration transformation templates use the following key elements of Handlebars syntax, together with enhancements specific
to ServiceNow CPQ:

* Handlebars expressions: Enclosed in double curly braces {{ }}, expressions enable administrators to insert variables, functions, or properties into the template. For example, {{user.name}} renders the value of the name property of the user object.
* Built-in helpers include conditional helpers and iteration helpers.
  * Conditional helpers enable you to render content conditionally based on a value. For example:
    * #if renders content if the condition is true.

          {{#if user.isActive}} 
            Active 
          {{/if}}

      This snippet renders "Active" only if `user.isActive` is true.
    * #unless -- The opposite of #if, it renders content if the condition is false.

          {{#unless user.isActive}} 
            Inactive 
          {{/unless}}

      This snippet renders "Inactive" if `user.isActive` is false.
    {#transaction-manager-integrations-handlebar-syntax__ul_pgb_qp2_hhc}
  * Iteration helpers let you loop through lists or modify scope.
    * #each loops through an array and renders content for each item.

          {{#each users}} 
            <li>{{this.name}}</li> 
          {{/each}}

      This snippet iterates through users and displays each user's name as a list item.
    * #with changes the scope to a specific object.

          {{#with user}} 
            <p>{{name}}</p> 
          {{/with}}

      This snippet simplifies access to properties of `user` in the block.
    {#transaction-manager-integrations-handlebar-syntax__ul_nbm_2p2_hhc}
  {#transaction-manager-integrations-handlebar-syntax__ul_imy_5fc_23c}
{#transaction-manager-integrations-handlebar-syntax__ul_ebt_w42_hhc}

## Advanced Handlebars syntax for integrations {#transaction-manager-integrations-handlebar-syntax__section_wxf_fq2_hhc}

Here's an explanation of each syntactical element used in the Integration Template, which leverages the Handlebars templating language.

* {{#if lines}} {{/if}}

  {{#if}} checks whether something is true.

  The following snippet checks whether there is something in `lines`. If `lines` has a value
  (like a list of items or some data), it will do something inside the block. If `lines` is empty or doesn't exist, it skips the block.

      {{#if lines}} 
        We have lines to process! 
      {{else}} 
        No lines available. 
      {{/if}}

  If `lines` exists, it shows "We have lines to process!". If not, it shows "No lines available."
* {{\~#each lines\~}} {{/each}}

  {{#each}} repeats something for each item in a list.

  The following snippet iterates over each item in the `lines` list and renders the content
  inside the block for every item. The \~ symbols are whitespace control characters in Handlebars. They help remove any extra spaces or line breaks before and after the block, ensuring cleaner and more compact output. (See
  below.)

      {{~#each lines~}} 
        <p>{{this}}</p> 
      {{/each}}

  The snippet goes through each item in `lines` and puts each item in a paragraph tag.
* {{#if \<cpq line-level field varname\>}} {{/if}}

  {{#if \<cpq ...}} checks whether a specific piece of data is true or exists. It checks whether a specific field or value (like
  varname) in your data exists or is true. It's a way to check for specific information in a more complex structure (like in a dataset).

      {{#if logik.lineLevelField.isActive}} 
        The field is active! 
      {{else}} 
        The field is not active. 
      {{/if}}

  This snippet checks whether `logik.lineLevelField.isActive` is true (like checking if something is "active"). If it is, it shows "The field is active!" If not, it shows "The field is not
  active."
{#transaction-manager-integrations-handlebar-syntax__ul_iq3_3q2_hhc}

## The tilde (\~) {#transaction-manager-integrations-handlebar-syntax__section_dzk_kvq_qhc}

The tilde (\~), a control character, hides whitespace and line breaks, helping keep the output clean. It makes HTML more compact and prevents spacing issues in output.

In some of the examples above, a leading tilde before #each removes whitespace before the block starts. The trailing tilde after #each removes whitespace after the block starts.

## The zeroIfMissing custom helper {#transaction-manager-integrations-handlebar-syntax__section_ffs_4vq_qhc}

The zeroIfMissing helper prevents errors due to missing values and ensures numerical fields always have a valid default value.

    Custom Helper 'zeroIfMissing'
    "price": {{zeroIfMissing txn.price}}, would become -> "price": 0 (or "price": 9.99, if txn.price is present)

## The lgkFilter custom helper {#transaction-manager-integrations-handlebar-syntax__section_tbj_2hc_23c}

The lgkFilter helper iterates through a collection and includes only items that meet a specified condition.

    {
      "numericFiltered": [
        {{#lgkFilter lines "txn.line.custom.someNumber > 10"}}
          {
          "id": "{{txn.line.product.id}}",
          "someNumber": "{{txn.line.custom.someNumber}}"
        }
        {{else}}
          {
          "error": "Item could not be added (numeric condition)"
        }
        {{/lgkFilter}}
      ],
      "textFiltered": [
        {{#lgkFilter lines "txn.line.custom.status == Active"}}
          {
          "id": "{{txn.line.product.id}}",
          "status": "{{txn.line.custom.status}}"
        }
        {{else}}
          {
          "error": "Item could not be added (text condition)"
        }
        {{/lgkFilter}}
      ]
    }

This helper replaces #each and #unless blocks.

* Simple syntax: {{#lgkFilter lines "\<predicate_field\>"}}
* Conditional syntax: {{#lgkFilter lines "\<predicate_field\> \<comparator\> \<literal_value\>"}}
* Supported comparators: \<, \>, \<=, \>=, !=, ==
* Complex conditions such as \&\& are not supported
{#transaction-manager-integrations-handlebar-syntax__ul_xwh_whc_23c}

The `else` block is supported within the helper.

The helper throws an error when its syntax is incorrect and when fields cannot be parsed.

The helper performs comma joins internally for valid JSON output.

## The @ symbol {#transaction-manager-integrations-handlebar-syntax__section_prv_qvq_qhc}

The @ ensures that you're pulling the value from the outer or parent context and not from the current context. It's often used when the data you need is at a higher level in the structure, and you want to avoid confusing it with
the local data of the current scope.

In the expression "LGK__TransactionId__c": "@{parentTransaction.id}", the @ symbol is used to reference a value from a parent context or object in templating systems, such as Handlebars or other
similar systems.

The @{} syntax tells the system to look at the parent context (the object or data outside the current scope) and retrieve the value of `parentTransaction.id`.

For example, suppose you have an object like this:

    { 
      "parentTransaction": { 
        "id": "12345" 
      } 
    }

When you use "LGK__TransactionId__c": "@{parentTransaction.id}", the `id` from `parentTransaction` (which is `12345`) will be used as the value for
"LGK__TransactionId__c".

## Conditional assignment example {#transaction-manager-integrations-handlebar-syntax__section_rp2_r3c_23c}

The line "LGK__ParentTransactionLineId__c": {{#if txn.line.custom.parentLineReferenceId}} "@{line_{{txn.line.custom.parentReferenceId}}.id}" {{else}} null {{/if}} is part of a Handlebars template and conditionally
sets the value of the field `LGK__ParentTransactionLineId__c`.

* `LGK__ParentTransactionLineId__c` is the key where the resulting value will be placed.
* {{#if txn.line.custom.parentLineReferenceId}} checks whether `txn.line.custom.parentLineReferenceId` exists and has a value.
* @{line_{{txn.line.custom.parentReferenceId}}.id} creates a dynamic reference to the `id` of a specific line based on `parentReferenceId`.
* {{else}} null {{/if}} sets the value to null if the condition is false.
{#transaction-manager-integrations-handlebar-syntax__ul_qwh_qs2_hhc}

## Concatenating Salesforce fields with conditional punctuation {#transaction-manager-integrations-handlebar-syntax__section_kzs_vvq_qhc}

In Handlebars, concatenating multiple fields together with punctuation (like commas, spaces, and conditional checks) can be done by combining variables in the template and using {{#if}} blocks to handle conditional logic.

For example, you can use the following approach to concatenate fields such as street address, street address2, city, state, and zip code for an address while ensuring that a comma and space after street address2 are only included
if street address2 is populated:

    {{#if streetAddress}} 
      {{streetAddress}} 
      {{#if streetAddress2}}, {{streetAddress2}}{{/if}} 
      {{#if city}}, {{city}}{{/if}} 
      {{#if state}}, {{state}}{{/if}} 
      {{#if zipcode}}, {{zipcode}}{{/if}} 
    {{else}} 
      No address available 
    {{/if}}

This concatenates fields like streetAddress, streetAddress2, and city, ensuring that commas are only included when the corresponding fields are populated.

Example output with `streetAddress2`: "123 Main St, Apt 4, San Francisco, CA, 94105"

Example output without `streetAddress2`: "123 Main St, San Francisco, CA, 94105"

## Conclusion {#transaction-manager-integrations-handlebar-syntax__section_ul3_bwq_qhc}

By using these key elements, administrators can create dynamic, flexible, and maintainable integration transformation templates. Understanding and leveraging expressions, helpers, blocks, conditionals, and parent context references
enables handling complex data and logic with ease.  
For more information on Handlebars syntax, see the [Handlebars documentation](http://handlebarsjs.com/).  
Note:  
Handlebars syntax does not support all the features described in this external document.

