Scheduling a workflow for recurring execution has been long awaited in WFA, perhaps from 2.0 time. The following document shows how to get it done. I've also explained the logic behind it. It’s very simple to use, meets every requirement which one can have from a scheduler and of course highly flexible.
The Real stuff. What is this? Is this actually a scheduler?
No. This is actually a command in your workflow, but a special 'magical' command. This 'magical' command logic is built using the answers for the following questions:
I've ticked all boxes needed to build such a solution. The solution is to make the workflow a smart workflow, so smart that it can schedule itself for the next execution. It no longer needs any other task scheduler to tigger it.
WFA provides a large set of REST APIs for other 3rd part SW integration. But I also can make good use of these APIs to make smart workflows. I have always believed that WFA should not only be seen as a framework for automating Storage boxes or server, but just about any task( inside a computer of course) which is done manually. WFA is an awesome product indeed.
So this is a command called "Workflow Scheduler" which you can put in your workflow as another command.
Username: <WFA Admin/Architect Username>
Password: <User Password>
3. Minimum WFA version 2.2. This is only needed for Importing the dar. I've provided the command code in text too. The command code is the real deal.
How to use it?
If you have a workflow which you want for recurring executions, just add this command "Workflow Scheduler" in it. The command takes parameters for the workflow execution intervals. For example minsInterval for executing this workflow every x minutes, or daysInterval for executing the workflow etc.
Now just like a normal workflow execution execute this workflow deciding what is the trigger time.
Example: Suppose you want the execution every day at 10:00 PM.
So provide daysInterval = 1
And execute the workflow for a delayed execution at 10:00 PM. You can pick the day to start as you wish. The workflow will execute at 10:00 PM and when this execution reaches our magical command "workflow scheduler", this command will trigger the same workflow with same set of inputs for the next execution at 10:00 PM tomorrow. And so on an so forth.
I’ve attached a very simple example workflow here to help you understand.
An Example of a workflow scheduled for recurring execution Daily at 11:30 PM starting 10-March-2015
How to stop/suspend this recurring execution?
Easy. You just abort the next scheduled job execution in Execution=> Execution Status. The cycle will stop.
How to resume it?
Easy again. Just resume the same aborted job. The cycle restarts.
Can I change the schedule execution time?
Yes. After aborting the current execution, you can resume the same workflow at a new time. Execution interval can't be modified as you can't change the command parameters. But the recurring execution now can occur at a new time.
Where or which position to place this “workflow scheduler” command in your workflow? At the beginning ? At the end? Or somewhere in the middle.
This completely depends on your choice. See some below cases.
So it’s all left to you.
Can an operator decide the execution schedule?
Yes, but which workflows will be available to him/her for this recurring execution will have to be decided by the designer. This is a good thing to have as it serves for access control in a way. The Architect/Admin can now restrict which workflow can be put for recurring executions. Operators can’t execute just any workflow available to him for automatic recurring execution.
And the workflow designer can also choose which scheduling parameter is to be made a variable for the operator. For example the designer want the operator to schedule a given workflow only for weeks Interval and not months or days i.e. he/she can only chose to schedule for weekly, biweekly etc. executions and nothing else. For this the designer can define a User-Input variable only for weeksInterval parameter. It’s Done.
You want workflow execution to be scheduled either for daily or once in 2 days but not any other. You can restrict this.
Or he/she wants to give full freedom to the operator make his/her own decision about scheduling, he defined user-input variable for all scheduling parameters.
The workflow designer wants weekly schedule but the day should not be a weekday: You can even do this.
Is this flexible enough for my requirements?
I’ve attached the very command code. You can modify the command as per your requirements.
Suppose you want daily execution of a certain workflow at 10:00 PM but skip a day of execution if the day is a Monday. Modify the code check for the day and add another day if it’s a Monday. Its posh code and highly readable.
So you can see how this can be used in a variety of ways. This is the beauty of a programmatic solution. Its highly flexible, it allows users to design solution based on their requirements.
Flexibility is the heart & soul of WFA. Thats why I like it.
I have a workflow but I don't want to modify it by adding a new command in it. Can I still use this solution?
Yes but with WFA 3.0 on wards. WFA3.0 allows to create modular workflows. Create a parent workflow with you actual workflow as a child workflow in it. Add our “workflow scheduler” command too. So now you don't need to touch your existing workflow. I've attached a workflow example here.
Providing a new version 1.1.0 of the command "WFA Schedular"
Below example for:
Schedule a workflow for recurring execution every alternate day i.e. once in 2 days at 10:30 PM starting 06-Jul-2015 (Today's date is 02-Jul-2015) . The recurring workflow execution should expire on 31-Dec-2015 and stop.
A WFA content is always forward or upward compatible. So a content created for WFA2.2 will work without any issues on a WFA3.0 and above.
The workflow WFA2_2_Workflow_for_Recurring_Execution_version1_0_2.dar will work on WFA3.0 without any isses. The workflow is a sample to help you understand how to use it. The real deal is the command "Workflow Scheduler" in this workflow. I ealier had also given a WFA 3.0 version just to show how to use the command in a Modular workflow ( available only from WFA3.0 and not below ).
So put teh command any of your workflows and get it going.