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:

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:

Considerations

When scheduling workflows, the following considerations apply:

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;
    }
}

See Also

Concepts

Workflows

Operations

Managing workflow execution

Reference

Web Service Reference