← Back to Blog

Dynamics CRM Unified Client - Open Task Flow via Javascript

Missing documentation for Xrm.Navigation.openTaskFlow

At the time of this blog post, Dynamics 365 Client API reference is missing the documentation for the "Xrm.Navigation.openTaskFlow" method.

Syntax

Xrm.Navigation.openTaskFlow(taskFlowName,taskFlowParameters,formParameters).then(successCallback,errorCallback);

Parameters

Name : taskFlowName
Type : String
Required: Yes
Description: Task Flow Unique Name

Name: taskFlowParameters
Type: Object
Required: Yes
Description: Entity form options for the Task Flow. The object contains the following attributes: 
  • primaryEntityContext: (Required) Object. Object containing the Entity Reference of the entity for the Task Flow. contains the following attributes:
    • id: (Required) String. ID of the entity record to display the Task Flow for.
    • entityType: (Required) String. Local name of the entity to display the Task Flow for.

Name : formParameters
Type : Object
Required: No
Description: A dictionary object that passes extra parameters to the Task Flow form.

For information about passing parameters to a form, see Set field values using parameters passed to a form

 

Examples

Example 1: Open "Update Contact" Task Flow

The following sample code opens the Update Contact Task Flow pointed at a specific contact.

JavaScript

var taskFlowParameters = { "primaryEntityContext" : {} };
taskFlowParameters["primaryEntityContext"]["entityType"] = "contact";
taskFlowParameters["primaryEntityContext"]["id"] = "065D05BB-742C-42C0-A522-C7E011592E47";

// Open the Task Flow.
Xrm.Navigation.openTaskFlow("update_contact", taskFlowParameters).then(
    function (success) {
        console.log(success);
    },
    function (error) {
        console.log(error);
    });
Example 2: Open "Update Contact" Task Flow 

The following sample code opens the Update Contact Task Flow pointed at a specific contact. in addition to setting field values on the Task Flow

JavaScript

var taskFlowParameters = { "primaryEntityContext" : {} };
taskFlowParameters["primaryEntityContext"]["entityType"] = "contact";
taskFlowParameters["primaryEntityContext"]["id"] = "065D05BB-742C-42C0-A522-C7E011592E47";

var formParameters = {};
formParameters["firstname"] = "Testy";
formParameters["lastname"] = "Testerson";

// Open the Task Flow.
Xrm.Navigation.openTaskFlow("update_contact", taskFlowParameters, formParameters).then(
    function (success) {
        console.log(success);
    },
    function (error) {
        console.log(error);
    });