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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Refreshing an associated sub-grid from a button using ribbon workbench

(0) ShareShare
ReportReport
Posted on by 365

I created a custom button to trigger an on-demand custom workflow using ribbon workbench

after my custom workflow finishing executing i want to refresh the sub-grid in my form, i added a custom JavaScript action but it doesn't work !!

Xrm.Page.getControl("opportunityproductsGrid").refresh();


is there anyway i can do this or another method to refresh my sub-grid ?

i am using Microsoft dynamics 365 online v9

thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hello Anas ,

    How did you know that  custom workflow has finished execution ?

    In ribbon action after execution of workflow using WEB  API request retrieve workflow status  and  inside success of WEB API request refresh the grid.

    In addition you can try to add parent in your code if you are not getting grid control.

    parent.Xrm.Page.getControl("opportunityproductsGrid").refresh();

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    >>How do you know that  custom workflow has finished execution ? Ideally you can not get these info sitting in client side  as custom workflow executed server side.

     what if this on-demand workflow is real-time?

    Even if worklfow is async it's possible to check if it finished or not. I haven't done it after 4.0 but if I was able to do it in 4.0 in 9.0 it's possible as well - a33ik.blogspot.com/.../how-to-calllaunchexecute-workflow-and.html

    Anas Rafik Can you please provide code that you use, screenshot of your workflow (I'm interested if it is background or async) and exact name of your subgrid - can you please provide screenshot of properties?

  • gdas Profile Picture
    50,091 Moderator on at

    Andrew ,

    I know it's real time but my point is that in JavaScript code not necessarily wait till workflow finishes execution which may take time , it may happen that grid refreshed earlier than workflow finish execution and user can't see the changes in grid.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Goutam,

    Everything depends on the way code is written. If refresh code is registered under successful execution callback - it should work. Agreed?

  • gdas Profile Picture
    50,091 Moderator on at

    Hi Andrew ,

    Yes you are correct , I have updated my answer with workflow status. Thanks for the idea.

  • Anas Rafik Profile Picture
    365 on at

    this is my screen shot of the workflow

    5661.screen3.PNG

    this how i call the workflow

    5661.screen3.PNG

    4113.screen2.PNG

    my sub-grid exact name is "opportunityproductsGrid"

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I'm afraid it will not work that way.

    You will have to use webapi to run a workflow and put refresh to "success" handler.

    You can use this article as a starting point - arvindcsit.blog/.../execute-workflow-using-web-api-in-dynamics-365

    Good luck

  • Verified answer
    Anas Rafik Profile Picture
    365 on at

    Yes it works thanks you very much but only when i change my workflow to run in the background but when i make it in real time it doesn't return success status

    this my code :

    function executeWorkflow(accountId, workflowParamId) {
        
            var entity = {
               "EntityId": accountId[0] // accountId
            };
             
            var req = new XMLHttpRequest();
            req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/workflows(" + workflowParamId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true);
            req.setRequestHeader("OData-MaxVersion", "4.0");
            req.setRequestHeader("OData-Version", "4.0");
            req.setRequestHeader("Accept", "application/json");
            req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            req.onreadystatechange = function() {
                if (req.readyState === 4) {
                    req.onreadystatechange = null;
             
                    if (req.status === 200) {
                        Xrm.Page.getControl("opportunityproductsGrid").refresh();
                    } else {
                        Xrm.Utility.alertDialog(req.statusText);
                    }
                }
            };
            req.send(JSON.stringify(entity));
        }
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Then don't change it to backgroud. Leave it realtime.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans