Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#824305
Dear Experts,
When I dedicate a special time for any task, and according to the assignment rules, any task must be done by the employee.
It is extremely obvious that, everybody have limited hours for working, and when the tasks are added,maybe they can not do the tasks in special time. The question is that, Can CE give a warning to prevent this? For example, when a manager or supervisor want to assign an individual to a group, a warning is appeared!( There is no capacity for this person) or these issues will be emerged in iBPMs?

Another question is that, I want to give some variables from the other programs which have API, or sometimes I want to send some variables from PM to the others programs, I know PM can handle them, but I do not know, which parts of wiki explains about these topics. I would be appreciated if you could give me some useful links and examples in wiki or pmusers.com
Looking forward to your comments
Kind Regards
#824334
mohamad wrote: Tue May 07, 2019 5:12 am Another question is that, I want to give some variables from the other programs which have API, or sometimes I want to send some variables from PM to the others programs, I know PM can handle them, but I do not know, which parts of wiki explains about these topics. I would be appreciated if you could give me some useful links and examples in wiki or pmusers.com
You can use Report Tables to export case variables to a database table. You can use an external reporting tool like Jasper Reports or Crystal Reports to visualize the data in the Report Table.
The other solution is to write a trigger which writes case variables to a database table or calls REST or web service of an external program.
#824336
mohamad wrote: Tue May 07, 2019 5:12 am When I dedicate a special time for any task, and according to the assignment rules, any task must be done by the employee.
It is extremely obvious that, everybody have limited hours for working, and when the tasks are added,maybe they can not do the tasks in special time. The question is that, Can CE give a warning to prevent this? For example, when a manager or supervisor want to assign an individual to a group, a warning is appeared!( There is no capacity for this person) or these issues will be emerged in iBPMs?
You need to change the ProcessMaker source code to add something like this. How would the code know if a user doesn't have enough time to be assigned to a task? You can't know this when designing a process, since the situation will change in the future when running cases.

The best way to handle this is to have a Process Manager who reassigns cases when users don't have time to handle them.
Another thing that you can do is use Value Based Assignment and have a trigger which randomly selects a user from the pool of assigned users to the next task and then query the APP_CACHE_VIEW table to figure out if the user is already assigned to a lot of cases. If so, then randomly select another user from the pool.

Something like this:
Code: Select all
$taskTitle = 'Task 2'; //set to the title of the Value Based Assignment task

$taskId = PMFGetTaskUID($taskTitle, @@PROCESS);
$d = new Derivation();
$aUsers = $d->getAllUsersFromAnyTask($taskId);
$max = count($aUsers) - 1;
if ($max < 0) {
      throw new Exception("No users assigned to $taskTitle");
}

//choose one user randomly from the assignment list:
$randomUser = $userToAssign = $aUsers[ rand(0, $max) ];
$found = false;

for ($i = 0; $i <= $max; $i) {
   //check if the user already has too many assigned cases
   $sql = "SELECT COUNT(*) AS NUMBER_CASES FROM APP_CACHE_VIEW WHERE 
      USR_UID='$userToAssign' AND DEL_THREAD_STATUS='OPEN' AND 
     (APP_STATUS='DRAFT' OR APP_STATUS='TO_DO')";
   $result = executeQuery($sql);
  
   //if less than 50 cases assigned to user then assign to next task:
   if ($result[1]['NUMBER_CASES'] < 50) {
       $found = true;
       break;
   }
   $userToAssign = $aUsers[$i]; //get the next user in list 
}

if (!$found) {
   $userToAssign = $orginalUser;
}

//assign user ID to variable used by Value Based Assignment in the next task:
@@assignedUser = $userToAssign;
#824347
amosbatto wrote: Tue May 07, 2019 10:12 pm
mohamad wrote: Tue May 07, 2019 5:12 am Another question is that, I want to give some variables from the other programs which have API, or sometimes I want to send some variables from PM to the others programs, I know PM can handle them, but I do not know, which parts of wiki explains about these topics. I would be appreciated if you could give me some useful links and examples in wiki or pmusers.com
You can use Report Tables to export case variables to a database table. You can use an external reporting tool like Jasper Reports or Crystal Reports to visualize the data in the Report Table.
The other solution is to write a trigger which writes case variables to a database table or calls REST or web service of an external program.
Thanks a lot,
About calls REST or web services of an external program, how can I do them. Would you please give me a link for it.
Kind Regards
#824368
See the documentation for how to call ProcessMaker's REST and web services. It is basically the same code for any external program's REST or web services. Also see these examples for how to use jQuery's .ajax() fuction to do a REST call:
https://wiki.processmaker.com/3.1/JavaS ... ing_jQuery
Clarification on Due Date

Thanks for the more information. It's strange that[…]

Hi Amos, Thank you for your kind attention. It is[…]

You can refer to the answer: https://forum.process[…]

Switch from Apache2 to Nginx

Hi, We used Processmaker 3.3.6. Processmaker Swit[…]