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

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Thanks Mike for your input. 

      If you know its initial value, then you will assign it at creation time. --  what if I don't know the value of the variable during initialization and the value would come after initialization as a result of some equation like we do in traditional programming. how to handle such scenarios.

Reply Children