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.
#824004
The type of assignment used by a task is set in the process map, so it can't be changed when running cases.

A task can use a Parallel Marker, so that it can be assigned to multiple users at the same time, but remember that each assigned user will overwrite the variables in the case, so you need to store the variables set by the user in an array (such as a grid) if you want to be able to recover those variables later.

You can use Set Variables: PUT /cases/{app_uid}/variable to send the assignment variable to the case before it gets to the task with the parallel marker.

There are other ways to assign a case to multiple users. See:
https://wiki.processmaker.com/3.2/Trigg ... r_of_Times

If you want to reassign a task that is already assigned to a user, then you can install my extraRest plugin and then use this REST endpoint:
https://www.pmusers.com/index.php?title ... ssign-case
#824023
kalinovski wrote: Tue Apr 16, 2019 4:18 am I need to reassign the task to an array of users.
These users are not members of any group.
They are selected dynamically from a list.

So is there a way to reassign the case to them via a PHP script?
If you have a checkgroup or a multiple select dropdown box, then you can populate the list of users with this SQL query of the ProcessMaker database:
SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) FROM USERS;
Then, the user can select the users to assign to the task.

If your PHP script is outside ProcessMaker, then you will need to use the REST endpoint PUT /cases/{app_uid}/variable or the sendVariables() web service to send the array of user IDs to the case. Then you can use one of the three methods that I explained in the previous post to assign the task to multiple users (Parallel Marker in one task, parallel tasks or serially with loop in process).
#824028
Basically, I'm trying to 'self service value based assign' an array of users to a task, then if no one claim's the case after a certain amount of time passes, a trigger reassigns the task to another array of users.

Your methods are designed for assigning the task to one certain user. I need it to be reassigned to an array of people. And all of the reassignment has to happen in the background by a trigger, without user manipulation.
#824037
I think you should write 1 API:
- Get out the pending cases
- claim case to inbox of the specified user
write a job periodically after an API call period

or even a risky way:
insert data into the table app_assign_self_service_value_group
- ID: ID of the table app_assign_self_service_value
- GRP_UID: ID of the special user
-> I am not happy with this way
#824039
kalinovski wrote: Wed Apr 17, 2019 2:53 am Basically, I'm trying to 'self service value based assign' an array of users to a task, then if no one claim's the case after a certain amount of time passes, a trigger reassigns the task to another array of users.

Your methods are designed for assigning the task to one certain user. I need it to be reassigned to an array of people. And all of the reassignment has to happen in the background by a trigger, without user manipulation.
This is complicated. Give a day or two to create a programming example for you at pmusers.com.

Here is the summary:
You need your Self Service Value Based Assignment task to have a loop-around with an exclusive gateway. Then, you need to create a separate process with a script task in a loop with an intermediate timer event that checks whether a certain amount has passed in the other process with the Self Service Value Based Assignment task. If too much time has passed, then use Cases::setCatchUser() to assign a user to the user, then use PMFSendVariable() to change the list of users in the array variable and then PMFDerivateCase() to route the case through the loop so it will start gain at the same task with a new set of users.

If this doesn't make any sense to you, then wait for me to write up a programming example.

The basic idea of an external timer is explained here:
https://www.pmusers.com/index.php/Send_ ... is_overdue

PS: Next time clearly explain what you want in your first post, so you don't waste people's time trying to guess what you want.
#824090
I figured out how to do this using the timeout for a Self Service Value Based Assignment task. I will write this up on the wiki tomorrow, but for now, here is the process:
(45.11 KiB) Downloaded 19 times
You need to change the triggers to set the usernames of the users that you want to assign to the task.

It also helps to create a 24 hour calendar like this to be used by task:
create24HourCalendar.png
create24HourCalendar.png (64.36 KiB) Viewed 944 times
Then, set your Self Service Value Based Assignment task to use the 24 calendar:
setTaskTo24HourCalendar.png
setTaskTo24HourCalendar.png (33.42 KiB) Viewed 944 times
Then, execute the cron.php script.
#824094
The case reassigned to the next users, it went to the new users in 'unassigned'...
But they cannot claim the case.
Any idea why?
And when I request the variables of the case via the API it returns the old userId's, not the new ones.
Attachments
SelfService2.png
SelfService2.png (50.16 KiB) Viewed 939 times
SelfService1.png
SelfService1.png (58.34 KiB) Viewed 939 times
#824127
Which version of PM are you using?

I tried the process in PM 3.3.8 Community and I see that it is affected by the bug with user permissions in PM 3.2.2 and later, and the fix that I posted doesn't solve the problem with claiming the case.

I looked through the code and see that the problem is with how \ProcessMaker\BusinessModel\Cases::userAuthorization() is processing the output from the Cases::getAllObjectsFrom() function, but I haven't figure out how to fix it.

If you are using the Community Edition, I recommend that you install PM 3.2.1 and don't upgrade until these bugs get fixed.

Also remember to add all the users in the assignment list for the Self Service Value Based Assignment task.

Thanks for your reply, Press F12 in your web bro[…]

I created a new process to make it easier to look […]

Genial!!! gracias. :D

This is resolved. I took a punt on Amos' suggesti[…]