Hi!
I am currently trying to make a function to set the pickup time or minutes. (This is a ticket tag)
The flow I would like to make is as follows:
- Click Automation Button “Set Pickup”
- Asks “Set Time or Minutes?”: Time Minutes or Cancel
3a-1. Click Minutes-> Prompts for “how many minutes?”
3a-2.Enter Minutes.
3b-1. Click Time->Prompts “Pickup Time”
3b-2. Enter Time.
3b-3. Check if pickup time is later than current time.
3b-4. If time is later, Pickup Time is set.
3b-5. If time is earlier, Asks: “Change to future date, Change Time, Cancel”
4a. Change to future date–> Prompts to select date.
4b. Change Time–>Go to step 3b1
4c. Cancel–> set Pickup Time to null
Now everything works well…other than step 3b-3.
The check works, but only the second time I input the time.
Here is my setup.
ACTIONS
Update Pickup Minutes
Ask Question
SCRIPTS
Name: getTime
Handler: tm
function getPickupTime(input) //we are not open in the morning, so all inputted times are returned as 24 hours format.
{
var hour = getHour(input);
var minute = getMinute(input);
var pickupTime = hour + “:” + minute;
return pickupTime;
}
function getHour(input)//returns the 24hour format hour
{
var hour = 0;
if(input.charAt(1) == “:”)
{
hour = parseInt(input.charAt(0));
hour = parseInt(hour) + 12;
}
if(input.charAt(2) == “:”)
{
hour = input.charAt(0) + input.charAt(1);
}
return hour;
}
function getMinute(input)//returns the minutes
{
var minute = " ";
if(input.charAt(1) == “:”)
{
minute = input.charAt(2) + input.charAt(3);
}
if(input.charAt(2) == “:”)
{
minute = input.charAt(3) + input.charAt(4);
}
return minute;
}
function getPickupMinutes(input, time)//get how many minutes until pickup
{
input = getHourNum(input);
time = getHourNum(time);
input = input - time;
return Math.round(input * 60);
}
function getHourNum(input)//returns the hours and minutes in a decimal format
{
input = parseInt(getHour(input)) + parseInt(getMinute(input))/60;
return input;
}
RULES
Step 1 & 2
Step 3a
Step 3b
The first Update Pickup Minutes Action Prompts the Pickup Time
[?Pickup Time;([1-9]|1[0-9]|2[0-3])(:)[0-5][0-9];;CO;49,50,51|52,53,54|55,56,57|39,48,8]
The second Update Pickup Minutes Action changes to 24 hour format.(If Time is less than 10:00 it adds 12 hours to it)(We are not open in the morning, so whatever time is inputted we assume that it is PM(eg: inputed “1:00”. returns “13:00”)
{CALL:tm.getPickupTime(’{TICKET TAG:Pickup Minutes}’)}
The 3rd action -Ask Question
Checks if {TICKET TAG:Pickup Minutes} is before {TIME}
the constraint is:
[=TN(’{CALL:tm.getHourNum(’{TICKET TAG:Pickup Minutes}’)}’)] <= [=TN(’{CALL:tm.getHourNum(’{TIME}’)}’)]
Prompts: Time must be later than {TIME}
Change to future order?
Buttons:Future Date,Change Time,Cancel
I have omitted Step 4a ~ c for this topic, as it is not used.
And the problem I am having is the constraint on the Ask Question on step 3b. The fist time I input any time, the ticket tag is set to that time, no matter the time. The second time I set the time, it will compare the time inputted originally, and the constraint for the ask question action kicks in.
EXAMPLE 1
Current time: 3:00PM
I input the time: 2:00
1st action - {TICKET TAG:Pickup Minutes} = 2:00
2nd action - {TICKET TAG:Pickup Minutes} = 14:00
3rd action - CONSTRAINT DOES NOT ACTIVATE
{TICKET TAG:Pickup Minutes} is now 14:00.
While the {TICKET TAG:Pickup Minutes} is 14:00
I input the time again. 2:00
1st action - {TICKET TAG:Pickup Minutes} = 2:00
2nd action - {TICKET TAG:Pickup Minutes} = 14:00
3rd action - CONSTRAINT ACTIVATES–> Asks Question
EXAMPLE 2
Current time: 3:00PM
I input the time: 4:00
1st action - {TICKET TAG:Pickup Minutes} = 4:00
2nd action - {TICKET TAG:Pickup Minutes} = 16:00
3rd action - CONSTRAINT DOES NOT ACTIVATE
{TICKET TAG:Pickup Minutes} is now 16:00.
While the {TICKET TAG:Pickup Minutes} is 16:00
I input the time again. 2:00
1st action - {TICKET TAG:Pickup Minutes} = 2:00
2nd action - {TICKET TAG:Pickup Minutes} = 14:00
3rd action - CONSTRAINT DOES NOT ACTIVATE
EXAMPLE 3
Current time: 3:00PM
I input the time: 2:00
1st action - {TICKET TAG:Pickup Minutes} = 2:00
2nd action - {TICKET TAG:Pickup Minutes} = 14:00
3rd action - CONSTRAINT DOES NOT ACTIVATE
{TICKET TAG:Pickup Minutes} is now 14:00.
While the {TICKET TAG:Pickup Minutes} is 14:00
I input the time: 4:00
1st action - {TICKET TAG:Pickup Minutes} = 4:00
2nd action - {TICKET TAG:Pickup Minutes} = 16:00
3rd action - CONSTRAINT ACTIVATES–> Asks Question
So from the above it seems that the constraint is checking {TICKET TAG:Pickup Minutes} only when the ticket tag already has the value, and not the newly entered value.
How am I able to make it check the ticket tag right away?
Any help is appreciated!
Thank you in advance!