Activate Order button is not working on Order Entity in UCI - CloudFronts

Activate Order button is not working on Order Entity in UCI

Posted On October 10, 2018 by Admin Posted in 

Introduction:

This blog explains an alternative approach to Activate an Order in UCI.

Scenario:

We are using Prospect to Cash solution to integrate Sales Order from Sales to Operations (CRM To Operations). In UCI Activate Order button is not working which is used for Order Integration. In this blog we will see an alternative approach to achieve this.

Pre-Requisites:

  •    D365 Sales
  •    Microsoft Flow

Steps to be followed:

Dynamics 365 –

1. Create Custom “Activate Order” button in UCI.

2. Add below JavaScript code which will trigger on Click of “Activate Order” Button.

(This code will take the Order Guid and pass it to the http post request)

Refer this blog to understand more about HTTP Post Request using Microsoft Flows: https://www.cloudfronts.com/http-post-requests-using-microsoft-flows/

// JavaScript source code
CallMSFlowsToActivateOrder: function () {
    var entityGuid = Xrm.Page.data.entity.getId();
    entityGuid = entityGuid.replace("{", "").replace("}", "");

    var data = JSON.stringify({
        "OrderID": entityGuid
    });

    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;

    xhr.addEventListener("readystatechange", function () {
        if (this.readyState === 4) {
            console.log(this.responseText);
        }
    });

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "URL Created From MS Flow", true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.send(JSON.stringify({
        "OrderID": entityGuid
    }));
} 

Microsoft Flow:

1. Create Flow from Blank.

2. Select the Http request is received trigger.

3. Add below in Request body JSON Schema

4. Add Get Record Trigger of Dynamics 365. In Item identifier pass the OrderId from the Dynamic Content.

5. List all related Sales Order Product of that Order.

6. Add apply to each control and update the value of Order is Active field.

7. Update the Processing state field of Order entity.

Overall Flow:


Share Story :