Page 1 of 1

How to assign ALL users onto a task?

Posted: Thu Jul 12, 2018 9:02 pm
by PipSqueak
Hi,

How do I dynamically assign all users onto a a generic task (e.g. leave request)?

Thanks

Re: How to assign ALL users onto a task?

Posted: Thu Jul 12, 2018 9:17 pm
by amosbatto
You can use PMFAddUserGroupToTask() want to add users to the assignment list for a task:
Code: Select all
$taskId = '1234567890abcdef1234567890abcdef'; //set to the ID of the task
$sql = "SELECT USR_UID FROM USERS";
$aUsers = executeQuery($sql);
for ($aUsers as $aUser) {
   PMFAddUserGroupToTask($taskId,  $aUser['USR_UID']);
}
If you need to assign all users to a task in a case, then use a parallel marker in the task.

Re: How to assign ALL users onto a task?

Posted: Fri Jul 13, 2018 4:47 am
by PipSqueak
Does this work with a starting task?

Re: How to assign ALL users onto a task?

Posted: Fri Jul 13, 2018 9:50 pm
by amosbatto
The recommended way to do this is create a group which contains all your users and then assign that group to the task. However, if you really want to do this, then set the trigger to fire before the case is created in the process properties.

By the way, your question is not clear. Are you talking about adding users to the assignment list of a task or are you talking about assigning users to a task in a particular case where the task has a parallel marker?

Re: How to assign ALL users onto a task?

Posted: Sat Jul 14, 2018 10:34 pm
by PipSqueak
I want all users to be able to start a process/case. For example, all users can request leave, so all of them should be assigned to it. But I wouldn't like to be adding the new users into that group every time, so is there anyway to do this dynamically? With a cron job perhaps?

Re: How to assign ALL users onto a task?

Posted: Wed Jul 18, 2018 1:36 am
by amosbatto
You could create a script which is executed as a cron job, but it is easier to create a process which periodically executes a script task which adds the users to a group. Then assign that group to the task.
See:
https://sourceforge.net/p/pmcommunity/c ... rsToGroup/

Re: How to assign ALL users onto a task?

Posted: Thu Jul 19, 2018 5:14 am
by PipSqueak
Thanks Amos! How do I buy you coffee (or beer)?

Re: How to assign ALL users onto a task?

Posted: Fri Jul 20, 2018 1:04 am
by amosbatto
Kind of hard, unless you are willing to ship it to La Paz, Bolivia. :-)