Skip to main content
February 3, 2022
Question

Using local variables in a rule that is used in reduce function from UI

  • February 3, 2022
  • 7 replies
  • 0 views

Hi,

Is there a way to use local variables in a rule that is used in reduce function When called from UI?

When Using from UI it says that I need to configure  refreahalways for the local variable .....

Thaks in advance,

Gil

    7 replies

    richardm900458
    February 3, 2022

    the information is pretty limited. can you tell as about your overall use case? 
    perhaps reduce() is not the right fit :) 

    gilt0001Author
    February 3, 2022

    Hi Richard,

    I am doing Shpitzer clearing schedule.

    For that I need to use values from previous iterations.

    To my understanding the only way to get results from previous iteration is with reduce.

    It works by the way - I just wasnt able to use local variables which made me repeat calculations...

    Thanks,

    stefanhelzle0001
    Brainy
    February 3, 2022

    That's pretty simple. a!localVariables does not re-evaluate local variables by default when used inside reduce(). To make this work, you need to declare the value of the local using a!refreshVariable and set refreshAlways to true.

    gilt0001Author
    February 3, 2022

    Thanks Stefan!

    Can you give an example? just how to declare the a!refreshVariable in the right context ?

    Thanks

    stefanhelzle0001
    Brainy
    February 3, 2022

    Your predicate expression has local variables. Update these similar to that example.

    docs.appian.com/.../Local_Variables.html