cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use dynamic formkey for user tasks?

prasobhraj
Star Contributor
Star Contributor
Hi,

Am creating a workflow to deploy in alfresco. In this one  user task formkey is depends on one field selected by the initiator. Is it possible to dynamically assign the formkey for a usertask?
6 REPLIES 6

jbarrez
Star Contributor
Star Contributor
Yes, formKey is an expression, so you can use variables in that expression that resolve to the actual form key.

hi ,
I tried to do with this using a variable like below
<code>
<userTask id="usertask1" name="User Task" activiti:candidateGroups="${agrmnt_management_execgp}" activiti:formKey="${agrmnt_management_exec_form}"></userTask>
</code>
and the form key is assigned by a service task as below
execution.setVariable("agrmnt_director_form","agrmntSmiley Very Happyirector"+(String) execution.getVariables().get("agrmnt_agreement_type"));
but its not working. the group id for the task got worked .
please help to sort this out

jbarrez
Star Contributor
Star Contributor
I'm not following here: should the variable that is set be named 'agrmnt_management_exec_form' instead of 'agrmnt_director_form' ?

prasobhraj
Star Contributor
Star Contributor
Hi,
Both agrmnt_management_exec_form and director form were there . Unfortunately i written the script mistakenly . i used the script as below
<code>
execution.setVariable("agrmnt_management_exec_form","agrmnt:ManagementExecutive"+(String) execution.getVariables().get("agrmnt_agreement_type"));
</code>
But its showing an error as
ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 0815430674 Wrapped Exception (with status template): Namespace prefix ${agrmnt is not mapped to a namespace URI
org.springframework.extensions.webscripts.WebScriptException: 0815430674 Wrapped Exception (with status template): Namespace prefix ${agrmnt is not mapped to a namespace URI

prasobhraj
Star Contributor
Star Contributor

Hi,

Anybody has a working solution. ?

gdharley
Elite Collaborator
Elite Collaborator

Seems to be working fine for me on Activiti 6 Beta.

I have a simple process:

I define a variable in the init script:

execution.setVariable("theForm", "formKey1");


I reference the variable for the form key in Task 1:

I run the process to Task 1 and retrieve the details using REST:

As we can see, form key is correctly populated.

Greg