Hello techies,
I need to use the merge() function on a dynamic list but it isn't proving easy.
Please check the following code snippet and suggest applying it on the dynamic list local!a.b
a!localVariables( local!a: { { a: 1, b: { 1, 2, 3 } }, { a: 2, b: { "asdf", 5, 6 } }, { a: 1, b: { 7, 8 } } }, { merge({ 1, 2, 3 }, { "asdf", 5, 6 }, { 7, 8 }), /*working*/ merge(local!a.b[1], local!a.b[2], local!a.b[3]), /*not working*/ merge(a!forEach(local!a.b, fv!item)) /*incorrect result*/
})
Discussion posts and replies are publicly visible
What is the intended outcome? And, why do you "need" to use the merge function?
Hi Stefan,
The intended outcome is merge({ 1, 2, 3 }, { "asdf", 5, 6 }, { 7, 8 }), somehow using local!a.b variable.
The use case is to build a table with columns local!a.a and dynamic rows based on combination of local!a.b
I still do not have a clear idea what the final output of this operation should look like. Your input data structure is:
{ { a: 1, b: { 1, 2, 3 } }, { a: 2, b: { "asdf", 5, 6 } }, { a: 1, b: { 7, 8 } }}
Now, what is the output?
Apologies for the misunderstanding, I am looking for the following merged output but using the variable local!a.b and not the values.
{{1, "asdf", 7}, {2, 5, 8}, {3, 6, null}}
So, from the original query;
merge({ 1, 2, 3 }, { "asdf", 5, 6 }, { 7, 8 }) works as the literal values results in desired output
however, merge(local!a.b[1], local!a.b[2], local!a.b[3]), does not work with the exact same values used in list of variants
merge() does not work here as it requires the individual lists to be separate parameters instead of a list of lists.