Question

Trigger callback function upon completion of business process execution

 

Hi all, 



Just wondering whether is there any way that we can run some javascript code / callback function upon completion of business process execution in client module?

 

If so, could you provide the sample code for reference?

 

Thank you very much.

Like 0

Like

2 comments

Hello,

 

If this is needed for versions lower than 8.0.6 (version when the LiveEditing feature was added out-of-the-box that will reload entity automatically in case changes to it were applied by a process) - you can always send a socket message to the client-side logic (like in the example but the message sending mechanism should be in the last script-task of the business process, on the client-side create a method that is triggered upon receiving the message)  or use an already-developed marketplace addon for it.

To elaborate more on what Oleg mentioned. There's no way to have a callback for when the process completes (the callback commented in your code is a callback for the completion of *starting* the process). A process can have things that wait for a period of time, so not really possible to wait for completion.

The approach to take is for the process to notify the client-code that it has completed by sending it a message. This article shows how to send the message: 

https://customerfx.com/article/how-to-refresh-a-page-from-a-process-in-…

If needed, this article shows how to receive the message in a Freedom UI page: 

https://customerfx.com/article/receiving-server-side-messages-in-a-crea…

However, if the page is Freedom UI, a better approach is to enable live data updates for the object so the refresh happens automatically when the data changes in the process. More about that here: 

https://customerfx.com/article/automatically-refreshing-a-creatio-freed…

From the code you posted, it looks like this is a classic page, so you'd have to go the first route for sending a message from the process to the client page.

Ryan

Show all comments