Managing workflow schedules
You can use the Workflow web service manage scheduled workflows, workflows that are automatically started by Nintex Workflow 2013. Scheduled workflows are managed by adding or removing workflow schedules, information stored in the Nintex configuration database that identifies the workflow to be started and describes the scheduling and association data to be used when starting that workflow.
Adding or updating a workflow schedule
You can use the following service operations from the Workflow web service to either add a new workflow schedule to or update an existing workflow schedule in the configuration database:
-
Adds or updates a workflow schedule, either for a site workflow or for a reusable or list workflow on a file in a SharePoint document library.
-
Adds or updates a workflow schedule for a reusable or list workflow on a list item in a SharePoint list.
Internally, Nintex Workflow 2013 uses a custom SharePoint timer job definition, named Nintex Workflow Scheduler, to start a timer job that monitors and, when needed, starts scheduled workflows. For more information about the Nintex Workflow Scheduler timer job, see Scheduled workflows and the Nintex Workflow Scheduler timer job.
By default, the Nintex Workflow Scheduler timer job checks the configuration database every 5 minutes, retrieving and evaluating the collection of workflow schedules. If a valid workflow schedule is ready to run, the timer job starts the workflow as indicated by the workflow schedule.
Removing a workflow schedule
You can use the following service operations to remove an existing workflow schedule from the configuration database:
-
Removes a workflow schedule for a site workflow from a site, or for a reusable or list workflow from a file in a SharePoint document library.
-
RemoveWorkflowScheduleOnListItem
Removes a workflow schedule for a reusable or list workflow from a list item in a SharePoint list.
Considerations
When scheduling workflows, the following considerations apply:
-
Scheduled workflows can be executed using a system account identity. However, this option is determined by a global setting in Nintex Workflow 2013, named Allow workflow schedules to impersonate the system account. If this option is disabled, an error occurs when attempting to execute any existing workflow schedules that use the system account.
-
As with any other automated process scheduled to run at certain times, external factors can affect the timing or execution of scheduled workflows. For example, if scheduled workflows conflict with other scheduled activities, such as patches or updates, errors may occur.
-
If multiple workflows are scheduled to run at the same time, the workflows are queued and may not start at the exact time indicated by the workflow schedule.
Example
The following example schedules the specified site workflow to run once every workday at 6:00 PM local time.
public bool ScheduleSiteWorkflowEndOfWorkday(string workflowName, string associationData) { try { // Instantiate a Schedule object, defined by the SOAP client. Schedule workflowSchedule = new Schedule(); // Define the schedule so that it runs once a day, on workdays, // starting today at 6 PM local time. workflowSchedule.RepeatInterval.Type = RepeatIntervalType.Daily; workflowSchedule.RepeatInterval.CountBetweenIntervals = 1; workflowSchedule.WorkdaysOnly = true; workflowSchedule.StartTime = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 18, 0, 0); // Use the AddWorkflowSchedule service operation to add a workflow schedule // to the configuration database. If a workflow schedule exists for the // specified site workflow, update it. var wsId = soapClient.AddWorkflowSchedule( "", workflowName, associationData, workflowSchedule, true); // If we received a workflow schedule identifier, return true; otherwise, // return false. return (wsId != null); } catch { // An error occurred while trying to schedule the site workflow. return false; } }