Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

On Demand Workflow Refresh

Posted on by 300

Hi,

I am using RibbonWorkbench to get a custom ribbon button to launch an on-demand workflow. All is working great.

My question is, when the workflow completes (it is a real time workflow) the box disappears but the grid (view) does not refresh.  You have to manually refresh the grid. This does not happen if you run it as a normal workflow using the Run Workflow button.

Is there any way to refresh the grid *after* the real time workflow has completed?

*This post is locked for comments

  • HenriquePalomo Profile Picture
    HenriquePalomo 510 on at
    RE: On Demand Workflow Refresh

    Could you resolve your problem?

  • HenriquePalomo Profile Picture
    HenriquePalomo 510 on at
    RE: On Demand Workflow Refresh

    Basically you need do this, see the example below:

    SmartButtons.ClientHooks.SmartButtons.RunWorkflow = function SmartButtons_ClientHooks_SmartButtons$RunWorkflow(name, entityId, completeCallback, errorCalback) {

       var fetch = String.format("<fetch count='1'>\r\n                       <entity name='workflow'>\r\n                           <attribute name='workflowid'/>\r\n                           <filter type='and'>\r\n                               <condition attribute='name' operator='eq' value='{0}'/>\r\n                               <condition attribute='ondemand' operator='eq' value='true'/>\r\n                               <condition attribute='statuscode' operator='eq' value='2'/> \r\n                               <condition attribute='type' operator='eq' value='1'/>     \r\n                           </filter>\r\n                       </entity>\r\n                   </fetch>", name);

       Xrm.Sdk.OrganizationServiceProxy.beginRetrieveMultiple(fetch, function(state) {

           var results = Xrm.Sdk.OrganizationServiceProxy.endRetrieveMultiple(state, Xrm.Sdk.Entity);

           var $enum1 = ss.IEnumerator.getEnumerator(results.get_entities());

           while ($enum1.moveNext()) {

               var row = $enum1.current;

               var request = new Xrm.Sdk.Messages.ExecuteWorkflowRequest();

               request.entityId = entityId.replaceAll('{', '').replaceAll('}', '');

               request.workflowId = row.getAttributeValueString('workflowid');

               Xrm.Sdk.OrganizationServiceProxy.beginExecute(request, function(executeState) {

                   var response = Xrm.Sdk.OrganizationServiceProxy.endExecute(executeState);

    if(response.message != undefined && response.message != null && response.message != "")

    {

     alert(response.message);

    }

    else

    {

     Xrm.Page.data.refresh(true);

    }

                   //if (completeCallback != null) {

                     //  SmartButtons.ClientHooks.SmartButtons.WaitForWorkflowToComplete(response.id, completeCallback, errorCalback, null);

                 //  }

               });

               break;

           }

       });

    }

    1. You need to call your JS function from the Ribbon Button.

    2. You need to get a response from your Workflow execution

    3. Check the response like in example above and do what you want to do, like refreshing the page or grid.

  • mluce Profile Picture
    mluce 300 on at
    RE: On Demand Workflow Refresh

    Hi,

    I do not know how to add a callback on the ribbon workbench command which calls the workflow. below is the snip of how the button is configured in workbench. Ideally, I would add a callback to this.  If I just add another action after it the grid refreshes before the workflow comes back.

    7635.rw.PNG

  • HenriquePalomo Profile Picture
    HenriquePalomo 510 on at
    RE: On Demand Workflow Refresh

    What button is not refreshing the page? The common button or the Smart Workflow button?

    If you are using the normal one, you should do a callBack javascript function to refresh the grid after action completed.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans