Page 1 of 1

Ability to dynamically handle assignments?

Posted: Tue May 14, 2019 1:05 pm
by njohns
We're evaluating whether PM will fit our needs or not. Currently we're using SharePoint and Nintex on top of that. We have a lot of different buildings that each operate on their own. They have their own approval systems. Until the processes get to headquarters each building operates almost as it's own company.

Right now for task assignments we do a lookup to a master list. It has each building listed and then a lot of columns named after each approval position with AD accounts listed in each position. So each time a workflow is initiated we do a lookup against that list, filtered down to the building selected in a drop down on the form, and then use set those approvers as different variables to be used throughout the process.

In almost every case we don't use groups, we assign directly to specific AD accounts. We do not assign to each and every approver per building, as we may skip certain approval positions if they do not need to be in those workflows.

Also, options chosen on the form itself may determine if additional approvers are added or not.

Is something similar available in PM OOTB? If not, is there a suggested way to handle that?

Re: Ability to dynamically handle assignments?

Posted: Tue May 14, 2019 8:46 pm
by amosbatto
There is no easy way to do that in ProcessMaker, but it can be done if you are willing to write a little code.

You could create two PM Tables which contain the users in each building and the approvers for each building. Then, use Value Based Assignment for the tasks where the approvers will be assigned. You can use conditions in gateways to skip approval tasks.

For example, let's say that you have the following process:
MultipleApprovalLevels.png
MultipleApprovalLevels.png (27.98 KiB) Viewed 3004 times
Where the "Level X Approval" tasks use Value Based Assignment.

Then, you can have a trigger in the first task that looks up information in the PM Tables to assign the users to the tasks and create the variables that are used in the gateway conditions to either do or skip the Approval tasks.

For example:
Code: Select all
//Lookup the building and approvers based on the logged-in user making the request:
$username = @@USR_USERNAME;
$sql1 = "SELECT A.APPROVER_ID FROM PMT_APPROVERS AS A 
   JOIN PMT_USERS_BUILDING AS UB ON UB.BUILDING_ID=A.BUILDING_ID 
   WHERE UB.USERNAME='$username' AND A.APPROVAL_LEVEL=1";
$result1 = executeQuery($sql1);
@@level1ApproverId = empty($result1) ?  '' : $result1[1]['APPROVER_ID'];

$sql2 = "SELECT A.APPROVER_ID FROM PMT_APPROVERS AS A 
   JOIN PMT_USERS_BUILDING AS UB ON UB.BUILDING_ID=A.BUILDING_ID 
   WHERE UB.USERNAME='$username' AND A.APPROVAL_LEVEL=2";
$result2 = executeQuery($sql2);
@@level2ApproverId = empty($result2) ?  '' : $result2[1]['APPROVER_ID'];

$sql3 = "SELECT A.APPROVER_ID FROM PMT_APPROVERS AS A 
   JOIN PMT_USERS_BUILDING AS UB ON UB.BUILDING_ID=A.BUILDING_ID 
   WHERE UB.USERNAME='$username' AND A.APPROVAL_LEVEL=3";
$result3 = executeQuery($sql3);
@@level3ApproverId = empty($result3) ?  '' : $result3[1]['APPROVER_ID'];
Where @@level1ApproverId, @@level2ApproverId, @@level3ApproverId are the assignment variables for the tasks "Level 1 Approval", "Level 2 Approval" and "Level 3 Approval", respectively. These same variables can be used in the gateway conditions, like this:

Go to Level 1 Approval: !empty(@@level1ApproverId)
Skip Level 1 Approval: empty(@@level1ApproverId)

Go to Level 2 Approval: !empty(@@level2ApproverId)
Skip Level 2 Approval: empty(@@level2ApproverId)

Go to Level 3 Approval: !empty(@@level3ApproverId)
Skip Level 3 Approval: empty(@@level3ApproverId)

Re: Ability to dynamically handle assignments?

Posted: Wed May 15, 2019 8:04 am
by njohns
Thank you for the in-depth reply! as well as SQL, what would you suggest new customers know if they wanted to extend PM beyond the OOTB features? PHP, JS, something else?

Edit: Nevermind, I found the answer to those questions here https://wiki.processmaker.com/3.1/developer_info