Page 1 of 1

Case Pausing until appointment w/ time tracking.

Posted: Thu May 11, 2017 5:03 pm
by Throwaway
Basically, I need to add a script task and a wait event in order for the process to keep the case paused until the date of the appointment so I can report on the time spent as well (how long is was paused for, etc)

I have everything setup but I'm stumped on the script part, is there a PMFunction that would suit this?

Image

Re: Case Pausing until appointment w/ time tracking.

Posted: Thu May 11, 2017 9:26 pm
by amosbatto
If you know the time of the appointment when the case is in the "Schedule Sign & Review" task, then you can use PMFPauseCase(). See this example.

If you don't know the time of the appointment and need to pause the case indefinitely while waiting for the appointment, then you will need to use a loop-around with an intermediate timer event and script task like this:
LooparoundWithScriptTask.png
LooparoundWithScriptTask.png (13.4 KiB) Viewed 3987 times
Your script task will periodically execute a trigger that checks whether the appointment has been set. If so it will set a variable that can be checked in the conditions in your exclusive gateway to either loop around again or continue with the next task.
Your 2 conditions in the gateway would be something like:
Go to Task 2: (!isset(@@continue) or @@continue != 'yes')
Go to Task 3: @@continue == 'yes'

Your trigger in Task2 would be something like:
Code: Select all
//need to set the condition to check if the appointment was set
if (...)  {
   @@continue = 'yes';
}
else {
   @@continue = 'no';
}
if you need to calculate the time, what are you trying to calculate? The time to complete a task, the time between two tasks, the time from the start of the case, the time between two datetime variables? Be more specific.

Re: Case Pausing until appointment w/ time tracking.

Posted: Fri May 12, 2017 8:50 am
by Throwaway
amosbatto wrote:If you know the time of the appointment when the case is in the "Schedule Sign & Review" task, then you can use PMFPauseCase(). See this example.

If you don't know the time of the appointment and need to pause the case indefinitely while waiting for the appointment, then you will need to use a loop-around with an intermediate timer event and script task like this:
LooparoundWithScriptTask.png
Your script task will periodically execute a trigger that checks whether the appointment has been set. If so it will set a variable that can be checked in the conditions in your exclusive gateway to either loop around again or continue with the next task.
Your 2 conditions in the gateway would be something like:
Go to Task 2: (!isset(@@continue) or @@continue != 'yes')
Go to Task 3: @@continue == 'yes'

Your trigger in Task2 would be something like:
Code: Select all
//need to set the condition to check if the appointment was set
if (...)  {
   @@continue = 'yes';
}
else {
   @@continue = 'no';
}
if you need to calculate the time, what are you trying to calculate? The time to complete a task, the time between two tasks, the time from the start of the case, the time between two datetime variables? Be more specific.
I am trying to calculate the time to complete the task since ProcessMaker doesn't calculate the time once it is paused if I'm not mistaken. The date will be coming from a calendar plugin. The date will show as AppointmentDate under casesDemo. I'm just not sure how to pull it to check if it has been met. APP_DATA (Array, 12 elements) -> AppointmentDate
Image

currently have:
Code: Select all
// Appointment date
$APP_DATA["AppointmentDate"] = $AppointmentDate;
	
// Today's date
$CurrentDate = date("m/d/y", time());

// Check if appointment date was met
if ($AppointmentDate >= $CurrentDate )  {
   @@DateMet = 'yes';
}
else {
   @@DateMEt = 'no';
}
Is something incorrect with the first syntax?

Re: Case Pausing until appointment w/ time tracking.

Posted: Fri May 12, 2017 8:27 pm
by amosbatto
If the format of your $AppointmentDate variable is "MM/DD/YYYY", then you need to convert to a timestamp to do the comparison between dates.

Try this:
Code: Select all
// Appointment date
$APP_DATA["AppointmentDate"] = $AppointmentDate;
$appointment = strtotime($AppointmentDate);
$today = strtotime(getCurrentDate());   

// Check if appointment date was met
if ($Appointment >= $today )  {
   @@DateMet = 'yes';
}
else {
   @@DateMet = 'no';
}