Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

Posted on by 256

Hi All,

I am using    Xrm.Page.getControl("fieldname").setNotification("Invalid");  for show the error notification on field in JavaScript. It is working fine.

But Xrm.Page.getControl("cyno_startdate").clearNotification() is not working for clear notification in Dynamics 365. 

If, I am using this alert(Xrm.Page.getControl("cyno_startdate").setNotification("Invalid Start Date")). Its return false.

Please suggest any solution ASAP.

Thanks! 

*This post is locked for comments

  • Suggested answer
    Pratices  Profile Picture
    Pratices 5 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Hi Ankit,

    I had one scenario that one you give more then 10-digit phone numbers it will give the warning even you are giving any alpha value as well.

    pastedimage1670990008919v1.png 

    pastedimage1670990091179v2.png

    Code: https://juniorcrmblog.blogspot.com/2022/12/how-to-make-field-only-take-10-digit.html

    In this code i have use setFieldNotification.

    Note : I have latest dynamic crm interview question.

    https://juniorcrmblog.blogspot.com/2021/08/ms-dynamic-crm-interview-question-for-2.html

    And This day I do video on dynamic DCRM.

    Call workflow directly from a button using Ribbon Workbench - YouTube

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    You really shouldn't be running with any code not working in turbo forms in 365. Who knows when the option to run legacy form will go away...

  • Suggested answer
    Syed Ibrahim Profile Picture
    Syed Ibrahim 6,257 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Can you try this below method. Which is working fine for  me. Make sure u enabled legacy form rendering as well.

    function commonEventHandler(executionContext) {
    var entityObject = executionContext.getFormContext().data.entity;
    var telephoneAttr = entityObject.attributes.getByName('telephone1');
    var isNumberWithCountryCode = telephoneAttr.getValue().substring(0, 1) === '+';

    // telephoneField will be an Xrm.Page control if invoked from a form OnChange event;
    // telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.
    var telephoneField = telephoneAttr.controls.getByIndex(0);

    if (!isNumberWithCountryCode) {
    telephoneField.setNotification('Please include the country code beginning with ‘+’.', ' ');
    }
    else {
    telephoneField.clearNotification('countryCodeNotification');
    }
    }

    scriptss.PNG

  • JokiJani Profile Picture
    JokiJani 25 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    It's a pug with Legacy form rendering. I Don't know any workaround.

  • HenriquePalomo Profile Picture
    HenriquePalomo 510 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Hello.

    Please use:

    Xrm.Page.getControl(arg).clearNotification(uniqueId);


    https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_clearnotification

    Regards.

  • AnkitSinghal Profile Picture
    AnkitSinghal 256 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    No. I used another solution for this now.

  • Mclare Profile Picture
    Mclare 1,395 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Did you get a solution . I am facing same issue  in dynamics 365

  • AnkitSinghal Profile Picture
    AnkitSinghal 256 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Hi Hemant,

    I have also tried that.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Hi Ankit,

    If form notifications are working for you then You can try setting some value when you show form notification and clear notifications something like var iserror = true/false. And then finaly in save, you check this value and prevent save accordingly

    Have not tried this but belives this should work. Worth trying.

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Xrm.Page.getControl("fieldname").clearNotification() is not working in Dynamics 365?

    Hi Ankit,

    This should work.

    Xrm.Page.getControl("fieldname").setNotification("message");

    Xrm.Page.getControl("fieldname").clearNotification();

    And you can't prevent Save by setFormNotification.

    The field notification will help you if you want to prevent Save.

    And one more thing I noticed,When tab is collapsed then the above code dont work.

    Thanks

    Hemant

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