Show Loading Message during function execution or Javascript load in CRM Form.

Hey CRM Folks, Today I am going to share one very interesting task that most of CRM folks face while working in CRM and play with Javascript. Many times Customers complaint that Javascript validations are avoided because the user performs operations before JS are completely loaded.

How can I check for the Condition ?
How could i restrict user to enter anything on the CRM form while JS not get fully loaded…….

Most of the times situation occur where user asked to show some processing message during long function execution, if you are doing some processing or calling any webservice which is taking time to execute and you want to show loading messsage to user.

Javascript : 

By using below mentioned Javascript function you can show Loading Message to user and can restrict untill JS get completely loaded.

function showJSProcessingMessage() 
{
    var formdiv = document.getElementById(\’dummyDiv\’);
    formdiv.disabled = true;

    document.getElementById(\’tdAreas\’).parentElement.style.display = \’none\’;
    var newdiv = document.createElement(\’div\’);
    newdiv.setAttribute(\’id\’, \’msgDiv\’);
    //newdiv.valign = \’middle\’;
    newdiv.align = \’center\’;
    newdiv.marginBottom = \’5000px\’;
    var divInnerHTML = \”\”;
    divInnerHTML += \”\”;
    divInnerHTML += \”\”;
    divInnerHTML += \”\”;
    divInnerHTML += \”

\”;

    divInnerHTML += \”Please wait while Script is Loading…\”;
    divInnerHTML += \”\”;


    divInnerHTML += \”\”;
    newdiv.innerHTML = divInnerHTML;
    newdiv.style.color = \’#001D72\’;
    newdiv.style.fontSize = \’13px\’;
    newdiv.style.zIndex = \’1010\’;
    newdiv.style.margin = \’0 auto\’;
    newdiv.style.marginTop = \’210px\’;
    newdiv.style.width = \’270px\’;
    newdiv.style.height = \’100px\’;
    newdiv.style.background = \’#FFFFE4\’;
    newdiv.style.border = \”thin solid #000000\”;

    //newdiv.style.width = getBrowserWidth()+\’px\’;
    //newdiv.style.height = getBrowserHeight()+\’px\’;
    newdiv.style.position = \’relative\’;
    document.body.insertBefore(newdiv, document.body.firstChild);
    document.getElementById(\’msgDiv\’).style.visibility = \’block\’;
   
    setTimeout(disableLoading, 10000); //use it to define ms for disable loading
    
}
function disableLoading() 
{
    if (document.readyState === \”complete\”) 
    {
        document.getElementById(\’msgDiv\’).style.display = \’none\’;
        document.getElementById(\”tdAreas\”).parentElement.style.display = \’block\’;
        document.getElementById(\’dummyDiv\’).disabled = false;
    }

}

Use this script on form OnLoad event :

Loading Message will look like below :

Hope this will someone…..You can use it based upon your project requirement.

Enjoy and Keep Reading !!! \\A/\\S/

Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

7 thoughts on “Show Loading Message during function execution or Javascript load in CRM Form.

  1. Nice one, Arpit.One suggestion, While using setTimeout(), we should use clearTimeout() along with the globally maintained scope variable. Else, the setTimeout will keep iterating after specified every time-interval and hence would might cause rendering slow down or even worse like halting UI, when the extensively custom js is loaded.

    Like

  2. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

  3. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

  4. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: