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

Comments

7 comments

  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    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
  • Matthew Foran

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

    0
  • Raul Bernales
    Celigo University Level 2: Seasoned
    Engaged
    Awesome Follow-up

    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
  • Raul Bernales
    Celigo University Level 2: Seasoned
    Engaged
    Awesome Follow-up

    Hi Matthew,

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

    0
  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

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

    0
  • Steve Klett Strategic Partner
    Celigo University Level 4: Legendary
    Answer Pro
    Great Answer
    Top Contributor
    Awesome Follow-up
    Engaged

    How many options is too many options?? :)

    {{#each GroupPricing}}{{[NuOrder Group Pricing]}}{{#unless @last}},{{/unless}}{{/each}}
    0
  • Raul Bernales
    Celigo University Level 2: Seasoned
    Engaged
    Awesome Follow-up

    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.