Application Studio - Events - row-update concatenate several values

Hi All,

I need to concatenate several columns from my TransView dataview into another column in a different dataview with each value separated by a comma. I need to suppress empty columns.

I’ve tried a few AI examples like so (in the Value field):

{
“event”: “row-update”,
“actions”: [
{
“type”: “SetColumnValue”,
“dataView”: “MyView”,
“column”: “CombinedField”,
“value”: “concat_ws(', ', {TransView.Col1}, {TransView.Col2}, {TransView.Col3})”
}
]
}

But these always give me an {Object object] error.

Has anyone successfully done this type of concatenation in App Studio events?

1 Like

I tend to favor JS Expressions here vs using JSON “Value”.

To suppress empty columns you can use an Expression like:

('{TransView.Col1}' ? '{TransView.Col1}' : '') + ('{TransView.Col2}' ? ( '{TransView.Col1}' ? ', ' : '' ) + '{TransView.Col2}' : '') + ('{TransView.Col3}' ? ( '{TransView.Col1}' || '{TransView.Col2}' ? ', ' : '' ) + '{TransView.Col3}' : '')

Its ugly, but basically (broken down):

For the first column: ('{TransView.Col1}' ? '{TransView.Col1}' : '')
If the column holds a value, display the value, otherwise, add nothing.

For the second column:
('{TransView.Col2}' ? ( '{TransView.Col1}' ? ', ' : '' ) + '{TransView.Col2}' : '')
If the second column holds a value, check if the first column held a value, if so, add a comma and then the 2nd column’s value, otherwise, add nothing.

For the third column:
('{TransView.Col3}' ? ( '{TransView.Col1}' || '{TransView.Col2}' ? ', ' : '' ) + '{TransView.Col3}' : '')
If the 3rd column holds a value, then check if Column 1 or 2 held a value, if so, include a comma + Col3’s value, otherwise, add nothing.

This is brute force, evaluating each column and could get unwieldly if you’re concatenating many columns.

5 Likes

Nice, I had 8 fields but was able to expand that syntax to the 8 fields. Works like a charm!! Thank you.

3 Likes