Skip to main content
gautams4173
April 13, 2023
Question

Append Values

  • April 13, 2023
  • 5 replies
  • 0 views

Hi,

I have a requirement to append the values of a particular computation to a local variable using append function 

The rule goes like this : 

a!localVariables(

local!data : {"x", "y", "z", },

local!finalValues,

a!forEach(

items: local!data,

expression: append(

local!finalValues,

performSomeComputation(fv!item)

)

)

)

now the problem is, the local variable is not getting updated no matter what, I tried using update dictionary as well as insert(local!finalValues, length(local!finalValues) + 1, fv!item) .. but still it wont append .. is there any other method I can use to append values ?

5 replies

mikes0011
Brainy
April 13, 2023

You would need to define local!finalValues as the a!forEach() update sequence you try below.  Expression code can't and doesn't "push" a value into an already-defined variable (the only exception being on a form where saves are executed via user interaction) - instead you need to build the update into your definitions.  It can be a tricky paradigm to get used to, I admit, but once you get it, it's pretty easy to follow.

mikes0011
Brainy
April 13, 2023

Also you would not need "append()" here - simply assemble your array.

a!localVariables(
  local!data: { "x", "y", "z",  },
  local!finalValues: a!forEach(
    items: local!data,
    expression: performSomeComputation(fv!item)
  ),
  
  local!finalValues /* for the sake of output only */
)

gautams4173
April 13, 2023

This works thank you 

amans0009
April 13, 2023

try this->

a!localVariables(
  local!data: { "x", "y", "z",  },
  local!finalValues: a!forEach(
    items: local!data,
    expression: concat("'", fv!item) /*some computation*/
  ),
  local!finalValues
)

gautams4173
April 13, 2023

Thanks it works