How to convert array values to string separated by commas

I need some guidance on converting an array to a string listing the element values separated by commas. I attempted to use the array.toString method but it doesn't seem to work. I'd greatly appreciate any help. 

Payload:
"properties": [
{
"name": "Engraved Text",
"value": "09/04/21 M&C"
},
{
"name": "Fill Color",
"value": "WHITE"
},
{
"name": "Engraved Font",
"value": "Bellefair"
}

Desired Result:
"Engraved Text:09/04/21 M&C,Fill Color:WHITE,Engraved Font:Bellefair"

Note - the array "properties" is a sub-array (not sure the terminology) of another array named "line_items"

1

Comments

1 comment
Date Votes
  • Hi Chris,

    The below handlebar should do what you need. If this is a subarray, you also need to wrap an {{#each line_items}} around it. Note that whatever field you're mapping this to is going to get one of these for every line item, and your final result would be all of them concatenated together. It seems like this should maybe be done with a JS hook to store the value in a new field, to easily be mapped 1:1, instead of handlebar statement.

    {{#each properties}}{{{name}}}:{{{value}}}{{#unless @last}},{{/unless}}{{/each}}

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post