Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Show loading image on save of Entity form

(0) ShareShare
ReportReport
Posted on by 15

I want to show loading image in the middle of screen on save of form as showing in below image, is there any way to replicate the same functionality as OOB save loading image.

I can't user Xrm.Page.data.save(saveOptions).then(successCallback, errorCallback); as save event is called from button on the form.

I implemented the logic on modifiedon field when updated then hide the loading image but this feature fails when there is some script error or custom plugin exception also it will fails on some other cases. Please help me in finding the workaround for this.

CRM 2016 On-prem 

pastedimage1622076192928v1.png

  • Suggested answer
    Charan Raju C R Profile Picture
    Charan Raju C R 7 Moderator on at
    RE: Show loading image on save of Entity form

    Hi Muhammad,

    Please refer to the below javascript code which is working fine for me in Dynamics 365 Online V9.2. As per your explanation, the only place you're facing problem is identifying if there is any error window prompted while loading image is displayed. In below script, I have added timeout function for keep checking for any error pop-up window opened for every half second. If the function find any error window, it closes the loading image. But identifying the error window is using DOM, which is unsupported. You may need to find out a supported way in your CRM version, if any.

    Also I have user Alert JS function to open saving dialog (refer: AlertJS if you're interested on this).

    Register onsave() on form save and modifiedonChanged() on modifiedon field change.

    Note: This is not a perfect solution. Because, loading image will remain open if the user closes the error pop-up window within half a second (before calling next timeout function checkErrorWindows). So, keeping minimum value for errorCheckInterval shall reduce this gap.

    var onSaveCalled = false, errorOccurred = false, errorCheckInterval = 500;
    
    function onsave() {
        showSavingPopup();    
    }
    
    function modifiedonChanged() {
        if (onSaveCalled) {
            errorOccurred = false;
            // Close the 'Saving..' dialog window when Modified On field changed
            new Dialog().hide();
        }
        onSaveCalled = false;
    }
    
    function showSavingPopup() {
        onSaveCalled = true;
        errorOccurred = false;
    
        if (Xrm.Page.data.entity.getIsDirty()) {
            // Open a dialog window with 'Saving..' title
            var options = { title: "Saving..", preventCancel: false };
            new Dialog(options).showLoading();
    
            setTimeout(checkErrorWindows, errorCheckInterval);
        }
    }
    
    function checkErrorWindows() {
        // Check if there is any error pop-up window opened.
        var maxPopupErrorWindows = 10;
        for (var i = 0; i < maxPopupErrorWindows; i  ) {
            if (!errorOccurred) {
                // This is unsupported. You may need to find a supported way to identify error window in your version of CRM.
                var errorWindow = parent.window.document.getElementById("DialogContainer__"   i   "_popupContainer");
                errorOccurred = errorWindow != null;
            }
        }
    
        // If no error pop-up windows opened, keep checking for every errorCheckInterval
        if (!errorOccurred && onSaveCalled)
            setTimeout(checkError, errorCheckInterval);
        // If any error pop-up windows found, close the 'Saving..' dialog window
        else if (errorOccurred)
            new Dialog().hide();
    }

  • RE: Show loading image on save of Entity form

    any one can help me here ?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans