Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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.
By rabbidwombat
#794539
Hi, I am new to ProcessMaker and trying to make what i thought was a simple Vacation Request workflow. as i thought out the process i realized that it isnt as simple as it sounds! I am having trouble makeing user that the correct person is who gets the task assigned to them. I do have my users set up in departments so User1 reports to User2 and Hr is User3 for example.
Process.JPG
Process.JPG (65.36 KiB) Viewed 2850 times
So as you can see, if User1 starts this process and step2 is HR approval (to make sure that the user has time available) when the job goes to the Supervisor of User1 the task wants to goto the Supervisor of HR. And anytime anyone rejects anything im not sure how to get it to go back to the original user that started all of this.

Am i just making this way more complicated than it needs to be? seems like it shouldnt be this hard. Thanks!
User avatar
By amosbatto
#794540
First of all, make sure that all your users who are assigned to the first task which is "Vacation Request" should be members of departments which have supervisors (or they should be supervisors of a subdepartment which has a supervisor in a parent department).

The first task should use Value Based Assignment and it should use the variable @@requesterId to assign the user.

Then, create a trigger with the following code:
Code: Select all
if (!isset(@@requesterId) or empty(@@requesterId) {
   @@requesterId = @@USER_LOGGED;
   $aUser = userInfo(@@requesterId);
   @@supervisorId = $aUser['reportsto'];
   if (empty(@@supervisorId)) {
      throw new Exception("Error: User ".@@USR_USERNAME." isn't assigned to a department.");
   } 
}
Set this trigger to execute before assignment in the first task.

Your third task, "Supervisor Approval," should also use Value Based Assignment and the variable @@supervisorId.
By rabbidwombat
#794563
Thanks! that worked!
only small issue was a missing ) at the end of the if statement...took me a bit to figure that out.

Thanks alot, the entire process seems to be working the way i would expect it!

corrected code for anyone else working with an issue like this:
Code: Select all
if (!isset(@@requesterId) or empty(@@requesterId)) {
   @@requesterId = @@USER_LOGGED;
   $aUser = userInfo(@@requesterId);
   @@supervisorId = $aUser['reportsto'];
   if (empty(@@supervisorId)) {
      throw new Exception("Error: User ".@@USR_USERNAME." isn't assigned to a department.");
   } 
}

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]

A Bet365 Clone Script is essentially a ready-made […]