DelegateTask

Delegates a workflow task to a user.

Syntax

public bool DelegateTask(
	int spTaskId,
	string taskListName,
	string targetUsername,
	string comments,
	bool sendNotification
)

Parameters

spTaskId
Type: System.Int32

Required. The identifier of the list item for the task. This parameter must be set to a value other than zero (0); otherwise, an error occurs.

taskListName
Type: System.String

Optional. The name or GUID of the task list that contains the task.

targetUsername
Type: System.String

Optional. The user to whom the task is to be delegated.

comments
Type: System.String

Optional. Comments to include in workflow history about why the task was delegated.

sendNotification
Type: System.Boolean

Required. Set to true to send a notification message to the user specified in targetUsername, indicating that the task has been delegated to the user; otherwise, set to false.

Returns

Type: Boolean

false if the outcome of the task is set to any value other than Pending, and therefore can no longer be delegated; otherwise, true if the task is successfully delegated.

Remarks

If the task list specified in taskListName or the task specified in spTaskId is not found, an error occurs.

The current user is determined by the credentials of the user context specified when this method is invoked. If the credentials of the current user context cannot be determined, an error occurs.

If the credentials of the current user context matches one of the approvers, assignees, or reviewers specified by the workflow action that created the task item, the method checks if the current user is allowed to delegate the task. If the current user is not allowed to delegate the task, an error occurs.

If the credentials of the current user context do not match any of the approvers, assignees, or reviewers specified by the workflow action that created the task item, an error occurs if the following requirements are not met:

Example

The following example demonstrates how to use this operation to delegate a workflow task to a user.

Request

The following SOAP request attempts to delegate a workflow task in the default task list to a user, sending a notification message to that user if the delegation is successful.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com">
   <soap:Header/>
   <soap:Body>
      <nin:DelegateTask>
         <nin:spTaskId>4</nin:spTaskId>
         <nin:taskListName>Workflow Tasks</nin:taskListName>
         <nin:targetUsername>testdomain\differentuser</nin:targetUsername>
         <nin:comments>Test delegation</nin:comments>
         <nin:sendNotification>true</nin:sendNotification>
      </nin:DelegateTask>
   </soap:Body>
</soap:Envelope>

Response

The following SOAP response indicates that the task was successfully delegated.

<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>
      <DelegateTaskResponse xmlns="http://nintex.com">
         <DelegateTaskResult>true</DelegateTaskResult>
      </DelegateTaskResponse>
   </soap:Body>
</soap:Envelope>

See Also

Operations

Delegating workflow tasks

Reference

AddLongTermDelegationRule

DelegateAllTasks

DeleteLongTermDelegationRule

Web Service Reference