Assignment to local variables in Expression rule

Certified Associate Developer

Hi,

I'm trying to save an array value to a local variable, it looks like getting saved, but when I check for the length of the local variable, I'm getting as 0. Where as when I save the same array during declaration of the local variable, I'm getting the length as expected. 

What I'm missing here ? what is the proper way of saving into local variables after declaring them. I've tried using a!save() but no luck.. :( 

Below are the snaps for your reference.

Assigning array after initialization 

Assigning array during initialization

  

TIA :)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    There are mainly only 2 places where you can "assign a value" to a local variable:

    1) at declaration

    2) as the result of a user interaction in an interface component

    Seeing as this is an expression rule, and therefore #2 is irrelevant, you will need to assign the value at declaration (#1). 

    This is the most important concept here: There is no such thing, in Appian's expression language, as "define a blank local variable then in a later line of code give it a new value".  If you know its initial value, then you will assign it at creation time.

Reply
  • +1
    Certified Lead Developer

    There are mainly only 2 places where you can "assign a value" to a local variable:

    1) at declaration

    2) as the result of a user interaction in an interface component

    Seeing as this is an expression rule, and therefore #2 is irrelevant, you will need to assign the value at declaration (#1). 

    This is the most important concept here: There is no such thing, in Appian's expression language, as "define a blank local variable then in a later line of code give it a new value".  If you know its initial value, then you will assign it at creation time.

Children