Dynamically Set Candidate Group in Task Listener

cancel
Showing results for 
Search instead for 
Did you mean: 
lsharman
Member II

Dynamically Set Candidate Group in Task Listener

Hi -

I'm using Activiti and want to dynamically set the Candidate Group for a task via the Create Task Listener. I'm using javascript in a task listener. I'm having two issues:

1) Setting the candidate group using a hard coded id works, but for portability, I need to set using a name. How do I get the group id from the group name in a Task Listener? The elements all seem to exist in the IdentityStore and GroupQuery, but I'm having issues putting it all together.

2) During development, I'm required to set an Assignee for this task. After setting the Candidate Group, how do I remove the assignee defined during the process definition? Currently, I'm setting the assignee to Candidate User Administrator since the Administrator won't be logging in, but I need to remove this assignment.

Also, is there documentation for scripting using javascript that might help me with other functionality?

Thanks
Lauren

3 Replies
ryandawson
Alfresco Employee

Re: Dynamically Set Candidate Group in Task Listener

Are you using the enterprise or the community application and which version? Also are you using the activiti database for user and group management? If you're using the community with the database identity management then you could look at this for the querying (albeit in java) - Activiti/GroupQueryTest.java at 6.0-release · Activiti/Activiti · GitHub 

I'm not sure what you mean about the assignee. Do you mean that there's something in your process definition that you want there for development purposes but you don't want in live? If so maybe you could change the xml definition?

lsharman
Member II

Re: Dynamically Set Candidate Group in Task Listener

Thank you for your response.  I'm using enterprise Activiti 1.6.1.  I am using the Process Editor and as much javascript as I can to develop the process. The process is executed via an ADF application (Java and Angular 2).  Your examples are java - can I not dynamically set the Candidate Group for a task using the Process Editor and javascript?  Does a programmer need to do that for me in the ADF application?

By Assignee, I mean the Assignee property on the task that I'm creating in the Process Editor.  This problem is related the first part.  For the process to pass validation in the Process Editor, I need to set the Assignee to something (Initiator, a Candidate Group, a person).  If I attempt to default it to a Candidate Group in the Process Editor, but then try to set it to a group id using javascript while testing the process during development, I receive an error.

Is there anyplace where I can find more information on what is accessible to me for javascript?

Thanks again

ryandawson
Alfresco Employee

Re: Dynamically Set Candidate Group in Task Listener

Ok,  you're porting the process from one enterprise deployment to another and the ids for users and groups naturally don't match. Presumably there are users and groups with the same names on the target environment as the names on the source environment. There is a checkbox on the process import popup to renew ids. By default the checkbox is not checked. You should try checking that checkbox and see if that does the match for you at the point when the process is imported as that would be simpler than writing any code. I would expect this to work for you. I assume you're not using alfresco publish tasks but if you are you should note that with 1.6.1 it may not renew the user/group ids for those ([ACTIVITI-717] Importing an app with a "Publish to Alfresco" task fails to renew the user ID of the ... ) as that was only implemented in 1.6.3. Since you're using enterprise if you hit an issue with the product you can of course make use of your enterprise support account to open a ticket.