In a lot of my projects, there comes a point where I require the user to wait for a certain flow to end. Unfortunately, it is not possible to create a synchronous flow similar to workflows. Therefore, we need to inform the user when a flow is initiated and when it is completed. If we initiate the flow using a javascript, we can easily accomplish this by displaying a message box when the flow finishes without any issues. However, what should we do if a flow takes a longer time to execute, such as several minutes? In such cases, I employ a status bar that appears when a record is opened and a flow is still in progress, performing calculations:

This messsage is displayed using a script, based on a status field at this specific table. I use, for example, the Yes/No field “FlowIsRunning”. This field is set to Yes when the flow starts the calculation, and again to No when it is finished (whether successfully or with an error).

 Subsequently, we aim to display the flow’s status on that specific record. To achieve this, I have developed a script that executes during the form’s onLoad event and periodically checks the status every 2 seconds. When the “FlowIsRunning” status is set to “Yes,” a message is displayed, which will be removed when “FlowIsRunning” is set to “No.” Here’s the script I have created: 

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
async function checkStatus(e){

    var formContext = e.getFormContext(); 
    var id =;
    while (true) {

        await Xrm.WebApi.retrieveRecord("opportunity", id).then(
            function success(result) {

                if (result.os_flowisrunning)
                    formContext.ui.setFormNotification("Please wait until the flow has ended...", "INFO", "FlowMessage");
        await sleep(2000);

I’m not a Javascript coding expert. So if anybody has suggestions, please let me know! (

Laat het ons weten!

Neem gerust contact op als je wat meer van onze dienstverlening wilt weten.