How do I read a process variable from inside a UserTask?

This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by Morten Lømo.

  • Author
  • #6124
     Morten Lømo

    This might be trivial, but I’ve been struggling for a while. Maybe someone can help ?

    I have a process. It contains a ScriptTask where I have a variable:

    rightsList = [“admin”, “operator”, “readonly”]

    I have also made the variable into a process variable:

    execution.setVariable(“rightsList”, rightsList)

    The next task in the process, is a UserTask which displays a form defined in an .xhtml file.

    My question is: How do I access the variable “rightsList” from this UserTask. I have tried many things, but none of them work:

    a) var optionArray = execution.getVariable(rightsList); //execution is not defined
    b) var optionArray = variable.rightsList; //variable is not defined
    c) var optionArray = getVariable(‘rightsList’); //getVariable is not defined
    d) var optionArray = ${rightsList}; //missing ; before statement
    e) var optionArray = {{variables.rightsList}}; //admin is not defined


     Morten Lømo

    Maybe I should add, the code in my ScriptTask is in Groovy whereas the code in my .xhtml file (UserTask) is in Javascript. I hope this is OK?



    Have you loaded the form data via this method to make it available to the form?

    TaskFormdata FormService.getTaskFormData(String taskId)
    You may want to refer to the Activiti user guide section 9.1
    Le me know if that made any difference.

     Morten Lømo

    I found a solution. In my .xhtml file (UserTask) I now do the following:

    <script type=”text/javascript”>
    var tmp = “{{variables.rightsList}}”;
    var optionArray = tmp.split(“,”); // optionArray now contains what I want


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

©2021 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?