How do i use variables defined in the Script Task in the User Task?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

How do i use variables defined in the Script Task in the User Task?

Jump to solution

Declaring variables in Script Task through execution.setVariable and using them in the User Task.

I have declared a variable in Script Task using execution.setVariable in the activiti Designer, but when i use the same variable through the ${expression} in the usertask and i click on the submit button when the process is run it says unable to evaluate expression.

This is what i have done.

Script Task:

message = "Hello"

execution.setVariable("msg", message)

User Task

Form Properities (String):

Expression:

${msg}

Format of the script is groovy.

Please Advice

1 Solution

Accepted Solutions
Highlighted
Active Member

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Thankyou so much Jonathan, i will look in to the variable section. Further more i figured out another way, there is a field where you can name a variable in the form properties right under the expression field, so i gave a name over there and it worked like a charm.

View solution in original post

5 Replies
Established Member II

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Asheer,

I believe when you use: execution.setVariable("msg", message), that's meant to set a Process Variables. From my understanding Activiti will not define a new variable for you if it doesn't already exist in the process, for example that "msg" value in your script. You would need to have a Process Variable named msg in order to store that information there.

Below is a GUI method for declaring a process variable:

 

Feel free to look into the Variables section of the User Guide for more specifics on utilization and declarations.

Hope this helps,
-JEarles

Highlighted
Active Member

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Thankyou so much Jonathan, i will look in to the variable section. Further more i figured out another way, there is a field where you can name a variable in the form properties right under the expression field, so i gave a name over there and it worked like a charm.

View solution in original post

Highlighted
Active Member

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Hi Jonathan, 

I looked out for the Variable in the GUI shown above in your screenshot, but my designer doesn't show that option.

I'm currently using Activiti Explorer 5.22.

Thanks.

Highlighted
Established Member II

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Asheer, 

My apologies - I'm glad you found your answer - but I was completely in left field in my original response.
You should be absolutely be okay using execition.setVariable() & task.setVariable() without ever defining them in the UI registries.

Glad you're back in working order Smiley Happy
-JEarles

Highlighted
Active Member

Re: How do i use variables defined in the Script Task in the User Task?

Jump to solution

Thank you for help Smiley Happy