Configure automation to run on a bi weekly cycle

Hi.

I am trying to create a custom run schedule that I can’t seem to figure out in Orchestrator. So I have been trying to implement in Studio.

Let’s say I have an automation that in a 2 week cycle is not supposed to run on alternating Tuesdays. So today is Tuesday, (MM/DD/YYYY) 07/02/2019. I do NOT want to run an automation today.

Next Tuesday 07/09/2019 I DO WANT to run an automation.

The following Tuesday 07/16/2019 I do NOT want to run an automation, and the cycle continues.

I need a longer term answer that can follow this cycle for years. What I tried was using DateTime variables and try to calculate how many days have passed and then using MOD 14 to determine if it is a every other Tuesday or not.

Assign → test = ((Today.Date - Date.Parse("07/02/2019")) MOD 14).ToString

where test = TimeSpan variable type.

I get the error:

Compiler error(s) encountered processing expression "((Today.Date - Date.Parse("07/02/2019")) MOD 14).ToString".
Operator 'Mod' is not defined for types 'System.TimeSpan' and 'Integer'.

Im not sure what to do next. I’ve tried changing the variable types and playing with the assign logic. This is the closest i’ve come to.

Main.xaml (5.5 KB)

Thanks!

If you want to calculate time difference check the following post

Or if you want to schedule the bot with a hot quick fix (actually a cheap shortcut :stuck_out_tongue: ) then schedule it every tuesday like below -

And keep a config file where you update the count - and if you want to run alternate weeks (let us say you DO NOT want to run on the 1st and 3rd week) then you can write a conditional statement that -

if(count mod 2)<>0

then bot will exit else it will run. One more condition required.

if(count = 4) - Update config file to count=1

I hope this helps :slight_smile:

Regards

3 Likes

Was typing out a solution essentially the same as @Raghavendraprasad - you’re too quick!

Schedule it to run weekly and have a file store a true/false, 1/0, or other type of flag. This can be in a config or pretty much anywhere that is accessible by all robots running this process. Put into your code the very first thing is to flip this flag, then either run the rest of the process or stop. If you do implement it this way, be sure the flag is flipped back in case of an error

2 Likes

Yup, flipping even when there is an exception is a major part. Thanks :slight_smile:

1 Like

@Dave @Raghavendraprasad Thanks for the response guys. Can either of you explain this config file idea a little more and what kind of error handling I need to look after? This sounds like a good idea I am just not getting how it would work.

Thanks!

I need to add on, my fault for not specifying: I do want to run everyday in a 2 week cycle except on that alternating Tuesday. So I can’t just schedule only on Tuesday’s and I don’t know if I can make that config logic work still.

In your excel/json config file just create a key called ShouldRun or something similar. This will be a boolean and the value should be either TRUE or FALSE.

In your workflow, the very first thing the robot should do is check that value CBool(Config(“ShouldRun”).ToString) - if the value is true, continue the workflow like normally. If false, change the value in the config file to TRUE and end the workflow.

I would set it up like this:

Read the ShouldRun flag in your main.xaml immediately after reading the config file. If true, continue to processing portion. If false, go to end portion. Your processing portion remains the same, but should have error handling within it so that on errors it will still go to the end portion so flag can be flipped. Put an activity in the end portion that flips the flag in the config file from True–>False (or False–> True).

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.