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.
#814044
Hello everyone,

I want to notify the manager of an employee 2 days before the employee begins his vacation.
I want to run a timer periodically to check whether this date has arrived and notify him accordingly.
What i have done is this : I created two parallel paths. On the top path, a script task runs based on the timer and checks the date to send the notification. The bottom path is the path with the main logic, where the manager approves the request or sends it for reevaluation.
What i would expect to happen is that the process could not continue until both paths converge to the gate (the top path runs again unless the request is approved). However, something goes wrong and when each path reaches the gate, a new case instant is created. And when the case is closed, according to the process diagram (reaches the endpoint), it still remains open in the system because two instances existed.

How can i solve this problem or is there a better way to run periodically a script task and send the notification?
Please, a solution is needed soon.

I provide printscreens of the process and the two instances.
Attachments
the process part with the timer.jpg
the process part with the timer.jpg (85.29 KiB) Viewed 2928 times
problem with timer event and case.jpg
problem with timer event and case.jpg (84.36 KiB) Viewed 2928 times
#814052
You have to set up a loop-around which periodically executes a script task. In that script task, execute a trigger which checks whether the date is two days before the vacation. Here are some examples:
viewtopic.php?f=44&t=709801&p=813037#p813037
viewtopic.php?f=44&t=730259&p=813499#p813499

How do you know when a user will be going on vacation? Have you set up a calendar for the user in ProcessMaker, or are you storing this information in a database table or are you using Datetime fields in the case variables of the process in your screenshot? If storing this information in case variables, then you should create a Report Table that will export this information to a table, so that it can easily be queried with executeQuery() in a trigger.

If you explain how you are storing the vacation dates, then I might be able to give you better instructions.
#814063
Thanks for replying Amos,

So basically, i store the values in case variables which i then store to an external database.
The employee at the beginning fills out a form with various information, including the date he/she wants to start his/her vacation.

In the process screenshot i initially uploaded, there is a loop with a script task and the timer event which executes it periodically. The loop executes while the request made from the employee is not approved yet (i check the value of a case variable i set upon approval "@@is_approved"). The script task does exactly what you describe, checks the date the employee has given with the current date and sends the notification based upon the difference in days. I'm guessing the problem might lie on the compatibility of the parallel gateway and a path that contains the timer event. What i'm trying to do now is to create an asychronous subprocess that contains this loop internally. I haven't tested that yet. A decision was made not to create a separate process in the way it is displayed in the example you told me to check because, as i understand, that way, this process will run indefinitely, every time the timer_event executes. However, if everything else fails, i might resort to using this separate process.

Ideally, i would like for every single case to have its own path with the timer event. I don't wan't to have a separate process that runs all the time to check all the pending cases and send the appropriate notifications.
#814065
What you are describing should work. Are you sure that the crontimerevent.php is executing? The first time it executes, it should set the timing for the next execution, so you have to execute it 2 times or more times for it to work. Also there are often problems with the time zone between PHP, env.ini and the operating system of the server.

Have you verified that your trigger works correctly when not in a script task? If not I recommend that you do. Also, keep in mind that if your trigger in the script task is using the system variables @@USER_LOGGED, @@USR_USERNAME, @@TASK and @@INDEX, then they will be set to the values of the previous normal task in your process, so they won't be up-to-date.

Finally, I recommend manually executing the crontimerevent.php file, to see if there is any output from the command line indicating an error. If using a Linux server, make sure to follow these instructions to execute the file as the Apache user:
http://wiki.processmaker.com/3.2/Execut ... p#In_Linux

Experience heightened pleasure with Cenforce 100 M[…]

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[…]