successcallback for async w/f? RRS feed

  • Question

  • Hello, I'm implementing an async w/f via js and I want to perform a js operation onsuccess, when the operation being executed by the w/f completes. However, it appears that the successcallback is being returned immediately after the w/f is triggered, as opposed to after the w/f completes. Here's the js:


    I'm guessing that this is because the success of ExecuteWorkflowRequest.js is based only on the successful trigger of the async w/f, as opposed to completion of the workflow b/c the only responsibility of ExecuteWorkflowRequest.js is to *trigger* the w/f. However, for the functionality I'm working on, I need to refresh the page only *after* the actual w/f logic completes.

    So, am I correctly understanding this gap? Is there a way to achieve what I'm trying to do?: call an async w/f via js and return onsuccess only *after* the w/f logic completes?

    Monday, April 7, 2014 9:05 PM

All replies

  • You are right in thinking that the ExecuteWorkflowRequest completes once the workflow is triggered, and this is beofre the overall workflow logic completes. There is no practical way that the ExecuteWorkflowRequest  could wait until completion of the workflow, as workflows can include Wait operations.

    The ExecuteWorkflowResponse includes the Id of the systemjob that represents the running workflow instance. You could periodically query CRM to check the status of this system job, and once the system job is complete, you could then refresh the page

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, April 7, 2014 10:09 PM