Skip to main content

Removing comma from filtered array

Comments

3 comments

  • Niranjan Thotapalli Senior Software Engineer

    Hi,

    We cannot solve this use case using handlebar expressions as the @last, @first, @index works based on the original array and not the filtered array. I would request you guys to make use of postMap hook to solve this usecase.

    Thanks.

    0
  • Sachin Godishela Software Engineer
    Answer Pro
    Great Answer
    Celigo University Level 4: Legendary

    Hi Hristina,

    As Niranjan as mentioned, we cannot solve this issue using just handlebars. Here's another workaround which might be helpful:

    Handlebars Template:

    {
        "id": {{id}},
        "customer_id": {{customer_id}},
        "date_created": "{{date_created}}",
        "date_modified": "{{date_modified}}",
        "status": "{{status}}",
        "Products": [ {{#each Products}}{{#compare name  "!=" "__Placeholder"}}
            {
                "id": {{id}},
                "order_id": {{order_id}},
                "product_id": {{product_id}},
                "variant_id": {{variant_id}},
                "order_address_id": {{order_address_id}},
                "name": "{{name}}",
              "sku": "{{sku}}",
                "quantity": {{quantity}}
            },{{/compare}}{{/each}}
            {}
        ]
    }

    In the import mappings, you can use this checkbox to ignore the empty object which we've added to the Products array.

    0
  • Anitha Abraham Community moderator Principal Technical Writer

    Hristina Bendeva I have moved this post under Troubleshoot custom flows.

    0

Please sign in to leave a comment.