Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Display mandatory field name when saving

Posted on by 815

Hi community,

By using this concept http://www.powerobjects.com/2015/09/23/dynamics-crm-alert-and-notification-javascript-methods/

i want to customize the notification, when ignore the mandatory field and click on save button, alert message show show the field name which is missed.

Please help !

Regards

Faisal

*This post is locked for comments

  • Syed_Faisal Profile Picture
    Syed_Faisal 815 on at
    RE: Display mandatory field name when saving

    Hi Gowtham,

    Thanks for correcting. 1 field was missing but now not getting any error nor notification alert on the top screen.

    Where will i get the message ?

  • Suggested answer
    sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Display mandatory field name when saving

    HI Faisal,

    Please check this article, it will give you clear idea -

    http://himbap.com/blog/?p=2634

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Display mandatory field name when saving

    Make sure you have wrote correct field name in the code. getValue is not getting as control with the field name  is not found which you have written.

  • Syed_Faisal Profile Picture
    Syed_Faisal 815 on at
    RE: Display mandatory field name when saving

    Hi,

    Getting erro. PFA

    23700.error.PNG

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Display mandatory field name when saving

    You can create one function and put the above code inside the function and  replace field name. Make sure you need to call the  function in the onsave event of the form.

  • Syed_Faisal Profile Picture
    Syed_Faisal 815 on at
    RE: Display mandatory field name when saving

    Hi Gowtham,

    What is the function name here to use?

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Display mandatory field name when saving

    Hi Sayed ,

    Hope below code will help you -

    // Field Notification 
    
    if (Xrm.Page.ui.controls.get("FieldName") != null && Xrm.Page.ui.controls.get("FieldName") == undefined) {
        var fieldVal = Xrm.Page.getAttribute("FieldName").getValue();
        if (fieldVal != null && fieldVal == undefined) {
            Xrm.Page.getControl("FieldName").clearNotification();
        }
        else {
            Xrm.Page.getControl("FieldName").setNotification("Please enter text.");
        }
    
    }
    
    //set  Form Notification
    
    
    if (Xrm.Page.ui.controls.get("FieldName") != null && Xrm.Page.ui.controls.get("FieldName") == undefined) {
        var fieldVal = Xrm.Page.getAttribute("FieldName").getValue();
        if (fieldVal != null && fieldVal != undefined) {
            Xrm.Page.ui.clearFormNotification("FormNotifiation1"); // Need to pass unique id which define to set notification in below line
            
        }
        else {
            Xrm.Page.ui.setFormNotification("Please enter text", "WARNING", "FormNotifiation1");
        }
    
    }
    


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans