Skip to main content
January 30, 2021
Question

set the value of a process variable in an expression

  • January 30, 2021
  • 7 replies
  • 0 views

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
January 30, 2021

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
January 31, 2021

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
January 31, 2021

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
February 8, 2021

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
February 8, 2021

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

The Expression Guru