How do I combine the array into one field with comma as its delimeter

Hoping someone can share their expertise.  I've got this Define Transformation Output below.  How can I combine the GroupPricing array into one field and using comma as it's delimeter?  Many thanks in advance.

{
  "id": "8532408",
  "Name": "Test Customer",
  "GroupPricing": [
    {
      "NuOrder Group Pricing": "Bags__33% CAD"
    },
    {
      "NuOrder Group Pricing": "Lifestyle__50% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 45__45% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 50__50% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 55__55% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 60__60% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 65__65% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 70__70% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 75__75% CAD"
    },
    {
      "NuOrder Group Pricing": "NC 80__80% CAD"
    }
  ]
}
0

Comments

7 comments
Date Votes
  • Raul Bernales would this work for you? Note you can't use handlebars in the export transform, but an use them in mappings downstream. You may also need to add record.GroupPricing to the initial each statement.

    {{#each GroupPricing}}{{[NuOrder Group Pricing]}},{{/each}}

    0
  • {
        "id": "{{id}}",
        "GroupPricing": "{{#each GroupPricing}}{{#if @index}},{{/if}}{{"NuOrder Group Pricing"}}{{/each}}"
        }

    0
  • Hi Tyler,

    That's exactly what I need.  Glad I finally was brave enough to ask.  Many thanks for sharing your knowledge.  Appreciate it a lot.

    0
  • Hi Matthew,

    That looks great too.  At least I have different approach right now.  Many thanks!

    0
  • Raul - Matthew’s is actually better because it won’t add a comma for the last string!

    0
  • How many options is too many options?? :)

    {{#each GroupPricing}}{{[NuOrder Group Pricing]}}{{#unless @last}},{{/unless}}{{/each}}
    0
  • Good day.  I hope I can still post here.  Let me know if I need to start another thread.

    Below is our current company sync to our B2B system.  Take note that a company can have multiple shipping addresses.  In this example, company 8512472 has two shipping addresses, while company 8571161 has only one.

    {
      "page_of_records": [
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "19000 North Fork Rd",
            "Address Country": "CA"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "7466 2 St",
            "Address Country": "CA"
          }
        },
        {
          "record": {
            "id": "8571161",
            "Name": "MOB Motosports",
            "Company Code": "8571161",
            "Currency Code": "USD",
            "Price Sheet": "35% USD",
            "Address Line 1": "161 May Hollow",
            "Address Country": "US"
          }
        }
      ]
    }

     

    We are trying to include the "pricing group" and below is the result when we modify the netsuite saved search.  

    {
      "page_of_records": [
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "19000 North Fork Rd",
            "Address Country": "CA",
            "Pricing Group": "NC 45"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "19000 North Fork Rd",
            "Address Country": "CA",
            "Pricing Group": "NC 60"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "19000 North Fork Rd",
            "Address Country": "CA",
            "Pricing Group": "NC 75"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "7466 2 St",
            "Address Country": "CA",
            "Pricing Group": "NC 45"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "7466 2 St",
            "Address Country": "CA",
            "Pricing Group": "NC 60"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "7466 2 St",
            "Address Country": "CA",
            "Pricing Group": "NC 75"
          }
        },
        {
          "record": {
            "id": "8571161",
            "Name": "MOB Motosports",
            "Company Code": "8571161",
            "Currency Code": "USD",
            "Price Sheet": "35% USD",
            "Address Line 1": "161 May Hollow",
            "Address Country": "US",
            "Pricing Group": "NC 45"
          }
        },
        {
          "record": {
            "id": "8571161",
            "Name": "MOB Motosports",
            "Company Code": "8571161",
            "Currency Code": "USD",
            "Price Sheet": "35% USD",
            "Address Line 1": "161 May Hollow",
            "Address Country": "US",
            "Pricing Group": "NC 60"
          }
        },
        {
          "record": {
            "id": "8571161",
            "Name": "MOB Motosports",
            "Company Code": "8571161",
            "Currency Code": "USD",
            "Price Sheet": "35% USD",
            "Address Line 1": "161 May Hollow",
            "Address Country": "US",
            "Pricing Group": "NC 75"
          }
        }
      ]
    }

     

    How can we transform that to combine the pricing group into one separated by comma. Below is what we want to achieve.

    {
      "page_of_records": [
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "19000 North Fork Rd",
            "Address Country": "CA",
            "Pricing Group": "NC 45,NC 60,NC 75"
          }
        },
        {
          "record": {
            "id": "8512472",
            "Name": "Pursuit Equipment & Sport Ltd",
            "Company Code": "8512472",
            "Currency Code": "CAD",
            "Price Sheet": "33% CAD",
            "Address Line 1": "7466 2 St",
            "Address Country": "CA",
            "Pricing Group": "NC 45,NC 60,NC 75"
          }
        },
        {
          "record": {
            "id": "8571161",
            "Name": "MOB Motosports",
            "Company Code": "8571161",
            "Currency Code": "USD",
            "Price Sheet": "35% USD",
            "Address Line 1": "161 May Hollow",
            "Address Country": "US",
            "Pricing Group": "NC 45,NC 60,NC 75"
          }
        }
      ]
    }

    Would appreciate any expert advise.  Thanks in advance.

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post