cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Seeking to run recipe outside of business hours only

JayMappus
Deputy Chef III
Deputy Chef III

Hi,

I would appreciate help on how to run a recipe Sat, Sun, and before 8:30am M-F and after 5:30pm M-Th and after 5:00pm F.   I've tried to set trigger conditions based (below) but I'm having trouble handling the 1/2 hours (8:30, 5:30 times) and identifying the M-Th and F schedule from the entire week. Below is what limited progress I've made. I couldn't figure out any other way, I couldn't make the Schedular work nor with cron. 

(CreatedDate.to_time.in_time_zone("America/New_York").wday == 0 ) ||
(CreatedDate.to_time.in_time_zone("America/New_York").wday == 6 ) ||
(CreatedDate.to_time.in_time_zone("America/New_York").strftime("%H").to_i < 8 ) ||
(CreatedDate.to_time.in_time_zone("America/New_York").strftime("%H").to_i > 17 )

Thank you in advance for sharing your time and knowledge.

J

 

3 ACCEPTED SOLUTIONS

steven-marissen
Executive Chef I
Executive Chef I

Hi there,

I think indeed CRON is not possible as you have to exclude too specific moments.
The next best thing I could come up with, would be the following (trigger every x):

stevenmarissen_0-1691611184249.png

In task 2, I created the variables as following:

  • Day (string): now.strftime("%A")
    • This gets the day name (day of week number also possible of course)
  • Special hour (boolean): if now.in_time_zone("Europe/Brussels").strftime("%k").to_i > 17 or now.in_time_zone("Europe/Brussels").strftime("%k").to_i < 8 then false else true end
    • This will return false if the hour is between 8 en 17 else true

In task 3, the variable is created  as following:

  • Special day (boolean): ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].include?(DayVariableTask2)
    • If the dayname is in the list, return true else false

If special day and special hour is true then do nothing, else do what is needed.

I know I skipped the half hours but from the above mentioned logic you can deduct that, it would work similarly

View solution in original post

Steven,

Your suggestions were excellent. You will see them sprinkled throughout the solution I came up with using your insights. I used a two-step filter approach to optimize use of the trigger to reduce cost. In the trigger condition I limited it to pulling down activities in the CRM (Insightly) that only occurred Sun, Sat and before 8am and after 5pm M, T, W, Th, Fri. Then at the next action I branched off 5pm - 5:30pm M, T, W, Th to stop and do nothing.  While I found your "Created Variable" beneficial to understand your approach, I did not use them to avoid task cost.  Thank you.

Screen Shot 2023-08-10 at 3.28.14 PM.png

View solution in original post

JayMappus
Deputy Chef III
Deputy Chef III

So here's how I solved the "before 8:30am Eastern time". I'm checking to see if the time the project is created is before 8:30am Eastern time on the same day. I'll bet there are more elegant solutions and would welcome anyone posting them.

(ProjectCreatedDatePill).to_time.in_time_zone("America/New_York") < (ProjectCreatedDatePill).to_time.in_time_zone("America/New_York").strftime("%Y-%m-%dT8:30:0%:z").to_time ).in_time_zone("America/New_York")

View solution in original post

4 REPLIES 4

steven-marissen
Executive Chef I
Executive Chef I

Hi there,

I think indeed CRON is not possible as you have to exclude too specific moments.
The next best thing I could come up with, would be the following (trigger every x):

stevenmarissen_0-1691611184249.png

In task 2, I created the variables as following:

  • Day (string): now.strftime("%A")
    • This gets the day name (day of week number also possible of course)
  • Special hour (boolean): if now.in_time_zone("Europe/Brussels").strftime("%k").to_i > 17 or now.in_time_zone("Europe/Brussels").strftime("%k").to_i < 8 then false else true end
    • This will return false if the hour is between 8 en 17 else true

In task 3, the variable is created  as following:

  • Special day (boolean): ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].include?(DayVariableTask2)
    • If the dayname is in the list, return true else false

If special day and special hour is true then do nothing, else do what is needed.

I know I skipped the half hours but from the above mentioned logic you can deduct that, it would work similarly

Steven,

Your suggestions were excellent. You will see them sprinkled throughout the solution I came up with using your insights. I used a two-step filter approach to optimize use of the trigger to reduce cost. In the trigger condition I limited it to pulling down activities in the CRM (Insightly) that only occurred Sun, Sat and before 8am and after 5pm M, T, W, Th, Fri. Then at the next action I branched off 5pm - 5:30pm M, T, W, Th to stop and do nothing.  While I found your "Created Variable" beneficial to understand your approach, I did not use them to avoid task cost.  Thank you.

Screen Shot 2023-08-10 at 3.28.14 PM.png

steven-marissen
Executive Chef I
Executive Chef I

Hi Jay,

Good to know that it helped you out and even better that you were able to reduce the overall task / job count! ๐Ÿ™‚

JayMappus
Deputy Chef III
Deputy Chef III

So here's how I solved the "before 8:30am Eastern time". I'm checking to see if the time the project is created is before 8:30am Eastern time on the same day. I'll bet there are more elegant solutions and would welcome anyone posting them.

(ProjectCreatedDatePill).to_time.in_time_zone("America/New_York") < (ProjectCreatedDatePill).to_time.in_time_zone("America/New_York").strftime("%Y-%m-%dT8:30:0%:z").to_time ).in_time_zone("America/New_York")