Skip to main content
Known Participant
Jan 30, 2021 1:49 PM UTC
Question

set the value of a process variable in an expression

Hello community,

is it possible to set/change the value of a process variable in a scripttask/expression for example when a condition is true other than node output is stored as.

I know how to set a value of a processvariable in the node output, but can it be done in like setting the value of a localvariable?
example:
if(pv!fruit="Apple",
pv!color:"green",
""
)

Kind Regars,

Erik

7 replies

csteward
Brainy
Jan 30, 2021 3:52 PM UTC

No, you cannot achieve this as in your code posted above - process variables will be updated on the data tab, node input or outputs.  What is your use case / where are you attempting to run this expression?

erikb0001Author
Known Participant
Jan 31, 2021 1:46 PM UTC

Hi Chris,

Thanks for you answer.
Now I know that there is no other way, I will use the node outputs in a scripttask to set the variables based on the expression with the condition.

Kind Regards.

Erik

mikes0011
Brainy
Jan 31, 2021 5:46 PM UTC

I guess it depends on what exactly you want to do.  If you want to set the value of pv!color to "green" when fruit is "apple", but otherwise not change the value of pv!color, you would simply set the following expression in your script task to save into pv!color:

if(
  pv!fruit = "Apple",
  "green",
  pv!color
)

The Expression Guru
erikb0001Author
Known Participant
Feb 8, 2021 7:20 AM UTC

Thank you Mike.
I wanted to know if it was possible not use the node outputs to make it more dynamic.
The Apple and colors was an example to illustrate my question.

Kind Regards,

Erik

mikes0011
Brainy
Feb 8, 2021 3:00 PM UTC

Can you give a bit more clarification as to what you're trying to accomplish, then?

The Expression Guru