AddWorkflowSchedule

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.

Syntax

public int AddWorkflowSchedule(
	string fileUrl,
	string workflowName,
	string startDataXml,
	Schedule schedule,
	bool updateIfExists
)

Parameters

fileUrl
Type: System.String

Optional. The absolute or relative URL of the file on which to add or update a workflow schedule for reusable or list workflows. If a relative URL is specified, the URL must be relative to the current SharePoint website.

To add or update a workflow schedule for site workflows, do not specify a value for this parameter.

workflowName
Type: System.String

Optional. The name or GUID of the workflow.

Note: Although the parameter is optional, an error occurs if a value is not specified.

startDataXml
Type: System.String

Optional. The association data to use for the workflow. If association data is not specified, default values specified for workflow variables in the workflow are used.

schedule
Type: Schedule

Optional. The details of the workflow schedule.

Note: Although the parameter is optional, an error occurs if a value is not specified.

updateIfExists
Type: System.Boolean

Required. Indicates whether existing workflow schedules can be updated. The behavior of the method changes depending on the value of this parameter, as described in the following table.

ValueDescription
true

If the specified file has existing workflow schedules for the specified workflow, then each existing workflow schedule is updated to use the association data and schedule details specified in, respectively, startDataXml and schedule, and the method returns the identifier of the existing workflow schedule that was last updated.

Otherwise, a new workflow schedule is created, and the method returns the identifier of the new workflow schedule.

false

If the specified file has existing workflow schedules for the specified workflow, then the method returns -1.

Otherwise, a new workflow schedule is created, and the method returns the identifier of the new workflow schedule.

Returns

Type: Int32

The identifier of the new or last updated workflow schedule; otherwise, -1 is returned if updateIfExists is set to false and workflow schedules for the specified workflow already exist for the specified file.

Remarks

The method runs within the context of the current SharePoint site, determined by the endpoint URL used to invoke the operation. For more information about invoking SOAP methods for Nintex Workflow 2013, see Service operations.

If the file URL specified in fileUrl or the workflow specified in workflowName cannot be found, an error occurs.

The time zone for the current SharePoint site is used when specifying date and time values for the properties of the Schedule object.

Setting Association Data

The startDataXml element contains an XML-encoded string, representing an XML fragment. The XML fragment is a single element, named Data, that can contain values for workflow variables defined in the workflow. For more information about using association data, see Using association data for starting workflows.

Note: You cannot include the Data element within the startDataXml element without first converting it to an XML-encoded string; otherwise, an error occurs. For an example, see StartWorkflowOnListItem.

Example

The following example demonstrates how to use this operation to add a workflow schedule for a list workflow on a file in a SharePoint document library.

Request

The following SOAP request adds a workflow schedule, which runs once a day on each workday that occurs between February 8, 2015 and March 1, 2015, for the list workflow named TestDocWorkflow on the file named TestDocument.txt.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com">
   <soap:Header/>
   <soap:Body>
      <nin:AddWorkflowSchedule>
         <nin:fileUrl>/Shared%20Documents/TestDocument.txt</nin:fileUrl>
         <nin:workflowName>TestDocWorkflow</nin:workflowName>
         <nin:startDataXml />
         <nin:schedule>
            <nin:MaximumRepeats>0</nin:MaximumRepeats>
            <nin:WorkdaysOnly>true</nin:WorkdaysOnly>
            <nin:RepeatInterval>
               <nin:Type>Daily</nin:Type>
               <nin:CountBetweenIntervals>1</nin:CountBetweenIntervals>
            </nin:RepeatInterval>
            <nin:EndOn>EndDate</nin:EndOn>
            <nin:StartTime>2015-02-08</nin:StartTime>
            <nin:EndTime>2015-03-01</nin:EndTime>
         </nin:schedule>
         <nin:updateIfExists>false</nin:updateIfExists>
      </nin:AddWorkflowSchedule>
   </soap:Body>
</soap:Envelope>

Response

The following SOAP response indicates that a new workflow schedule, with an identifier of 2, was successfully added.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <AddWorkflowScheduleResponse xmlns="http://nintex.com">
         <AddWorkflowScheduleResult>2</AddWorkflowScheduleResult>
      </AddWorkflowScheduleResponse>
   </soap:Body>
</soap:Envelope>

See Also

Concepts

Workflows

Operations

Managing workflow schedules

Reference

AddWorkflowScheduleOnListItem

Web Service Reference