Partilhar via


CreateWorkflowFromTemplateRequest Class

Definition

Contains the data that is needed to create a workflow (process) from a workflow template.

public ref class CreateWorkflowFromTemplateRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class CreateWorkflowFromTemplateRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")>]
type CreateWorkflowFromTemplateRequest = class
    inherit OrganizationRequest
Public NotInheritable Class CreateWorkflowFromTemplateRequest
Inherits OrganizationRequest
Inheritance
CreateWorkflowFromTemplateRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance. For the complete sample, see the link later in this topic.

/// <summary>
/// Demonstrates how to create a workflow record from a workflow template
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
/// <param name="processTemplateId">The ID of the template workflow</param>
static void CreateWorkflowFromTemplate(IOrganizationService service, Guid processTemplateId)
{
      CreateWorkflowFromTemplateRequest request = new ()
      {
         WorkflowName = "Workflow From Template",
         WorkflowTemplateId = processTemplateId
      };

      // Execute request.
      var response = (CreateWorkflowFromTemplateResponse)service.Execute(request);

      // Verify success.
      // Retrieve the name of the workflow.
      ColumnSet cols = new ("name");
      Entity newWorkflow = service.Retrieve("workflow", response.Id, cols);
      if (newWorkflow["name"] == "Workflow From Template")
      {
         Console.WriteLine($"Created {request.WorkflowName}.");
      }
}

For more code samples using workflow, see Sample: Workflow operations

Remarks

For the Web API use the CreateWorkflowFromTemplate action.

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of CreateWorkflowFromTemplateResponse.

Privileges and Access Rights

To perform this action, the caller must have privileges on the workflow entity and access rights on the record specified in the WorkflowTemplateId property. The prvCreateWorkflow and prvReadWorkflow privileges are required.

Constructors

CreateWorkflowFromTemplateRequest()

Initializes a new instance of theCreateWorkflowFromTemplateRequest class.

Properties

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
WorkflowName

Gets or sets the name of the new workflow. Required.

WorkflowTemplateId

Gets or sets the ID of the workflow template. Required.

Applies to

See also