Skip to main content

Notifications

Announcements

No record found.

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

  • Community Member Profile Picture
    on at
    RE: Allow Synchronous on-demand workflows to refresh the user's form

    Thank you all for the responses!

    Kylie: We will proceed with your suggestion.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Allow Synchronous on-demand workflows to refresh the user's form

    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));

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Allow Synchronous on-demand workflows to refresh the user's form

    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
    KylieKiser Profile Picture
    2,174 on at
    RE: Allow Synchronous on-demand workflows to refresh the user's form

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans