Skip to main content
November 17, 2022
Solved

Define variable later

  • November 17, 2022
  • 2 replies
  • 0 views

Hello!

I have a problem of following type:

a!localVariables(
  local!emptyArray: {},
  ...
  {
    ...
    a!forEach(
        ...
        a!localVariables(
            local!variableWhichChangesWithEveryIteration:{...},
            {
                /* Here I want to append the local variable's value to my empty array. Something like this: */
                a!save(local!emptyArray, append(local!emptyArray, local!variableWhichChangesWithEveryIteration))
            }
        )
    )
    /* my array will be used here */
  }
)

The problem is that value of the array won't refresh by itself (if I use saveInto in a textField, for example) and I don't know how to do it automatically...

Best answer by mikes0011

The trick is, in Appian, if your value isn't being supplied by user interaction, then there's no reason you can't just declare the variable that way up-front.  There's no need (and also no way) to declare a blank variable then have some subsequent function call change it for you.  That's because you can just declare it that way from the start.

a!localVariables(
  local!array: a!forEach(
    ...,
    "value that changes with each iteration"
  ),
  ...
)

2 replies

mikes0011
mikes0011Answer
Brainy
November 17, 2022

The trick is, in Appian, if your value isn't being supplied by user interaction, then there's no reason you can't just declare the variable that way up-front.  There's no need (and also no way) to declare a blank variable then have some subsequent function call change it for you.  That's because you can just declare it that way from the start.

a!localVariables(
  local!array: a!forEach(
    ...,
    "value that changes with each iteration"
  ),
  ...
)

The Expression Guru
stefanhelzle0001
Brainy
November 17, 2022

The Appian expression language is a functional language with immutable variables. Check out this: docs.appian.com/.../Expressions.html