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
Could you resolve your problem?
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.
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156