Skip to main content
Inspiring
Nov 17, 2022 6:42 PM UTC
Solved

Define variable later

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...

mikes0011
mikes0011Answer
Brainy
Nov 17, 2022 7:57 PM UTC

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

2 replies

mikes0011
mikes0011Answer
Brainy
Nov 17, 2022 7:57 PM UTC

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
Nov 17, 2022 8:17 PM UTC

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