web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Allow Synchronous on-demand workflows to refresh the user's form

(0) ShareShare
ReportReport
Posted on by

Hi,

We have a synchronous on-demand workflow that executes logic and then deactivates the record. After the workflow finishes executing, it does not refresh the UI. So, the user does not know if the workflow they activated actually deactivated the record.

Here's an article on the exact same question. Except that in our case, it's an on-demand workflow.
https://ideas.dynamics.com/ideas/dynamics-crm/808620

Any ideas on how to accomplish the form refresh while customizing as little as possible? We have CRM 2013 On-premise.

Best,
Tony

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    KylieKiser Profile Picture
    2,174 on at

    You cannot refresh the form with an on-demand workflow.

    Instead of triggering on-demand you could use a field on the form (checkbox to start the process) then use a Real-time workflow. If you have this fire on the save you should be able to have the save occur, implement your logic, and deactivate the record all as part of the save action. So the form will refresh.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    I think the option Kylie has suggested would be best for you as it involves less customization. You could also try a ribbon button and then from that ribbon button run your workflow followed by refresh the entity. This would requires more customization i.e. creating a ribbon, adding javascript code to run workflow and the refresh the entity.

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I think Kylie and Ravi are correct you need customization for that. You can introduce new button in ribbon and onclick of the button you can run the workflow and the refresh the form by using Xrm.Page.data.refresh().

    Here is the code for run workflow using JavaScript

    //Get the workflow id

    var workFlowName = "myWorkFlow";

    var workFlowId = "";

    var xmlData = Xrm.Page.context.getClientUrl() + '/XRMServices/2011/OrganizationData.svc/WorkflowSet?$select=WorkflowId&$filter=StateCode/Value eq 1 and ParentWorkflowId/Id eq null and Name eq \'' + workFlowName + '\'';

    var xmlHttp = new XMLHttpRequest();

    xmlHttp.open("GET", xmlData, false);

    xmlHttp.send();

    if (xmlHttp.status == 200) {

    var result = xmlHttp.responseText;
    workFlowId = //------ (write logic to parse workflow id from xmlHttp object)

    }

    //Calling workflow

    var functionName = "executeWorkflow >>";

    var query = "workflows(" + workflowId.replace("}", "").replace("{", "") + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow";

    var data = {
    "EntityId": accountId
    };

    var req = new XMLHttpRequest();

    req.open("POST", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.1/" + query), true);

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.onreadystatechange = function() {

    if (this.readyState == 4 /* complete */ ) {

    if (this.status == 204) {

    //success callback this returns null since no return value available.

    } else {

    //error callback

    }

    }

    };

    req.send(JSON.stringify(data));

  • Community Member Profile Picture
    on at

    Thank you all for the responses!

    Kylie: We will proceed with your suggestion.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans