Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

Posted on by 5

Field level notification is not getting cleared using Js, if working on different tabs. If fields are under different tabs, then only able to set notification not able to clear them. Function is returning true but it not clearing  the notification. Anyone facing similar issue? Thanks in Advance!! 

Referring JS Syntax  from: docs.microsoft.com/.../clearnotification

  • Suggested answer
    necsa Profile Picture
    necsa 3,455 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    My final suggest changing your if logic

  • necsa Profile Picture
    necsa 3,455 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Try to put clear syntax of notification beginning of the function.

  • AdityaTripathi Profile Picture
    AdityaTripathi 5 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi,

    Legacy rendering is already disabled and checked BR's also nothing else working on that field.

    Thanks

  • necsa Profile Picture
    necsa 3,455 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi,

    Is the legacy form active or disable. I suggest disable the legacy form and try it again.

  • AdityaTripathi Profile Picture
    AdityaTripathi 5 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi Necdet Saritas,

    Used unique Id concept also still unable to clear the notification.

    Thanks in Advance.

  • Suggested answer
    necsa Profile Picture
    necsa 3,455 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi,

    You must use "uniqueId" if you want to clear Notification.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/setnotification

    function referral(executionContext) {

    debugger;

    var formContext = executionContext.getFormContext();

    var jobtitle = formContext.getAttribute("jobtitle");

    var birtheDate = formContext.getAttribute("birthdate").getValue();

    if (jobtitle  != null )

                  {

    formContext.getControl("birtheDate").setNotification("department date  cannot be earlier than the contact with police", use "uniqueId");

    }

    else {

    formContext.getControl("birtheDate").clearNotification();  Here, you must complete with "uniqueId"  Look at above link

    }

    }

  • AdityaTripathi Profile Picture
    AdityaTripathi 5 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi Leah Ju,

    Done everything as you have suggested still it is not working. Please find below my code: Event onChange of field.

    function referral(executionContext) {

    debugger;

    var formContext = executionContext.getFormContext();

    var jobtitle = formContext.getAttribute("jobtitle");

    var birtheDate = formContext.getAttribute("birthdate").getValue();

    if (jobtitle  != null )

                  {

    formContext.getControl("birtheDate").setNotification("department date  cannot be earlier than the contact with police");

    }

    else {

    formContext.getControl("birtheDate").clearNotification();

    }

    }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi AdityaTripathi,

    If you don’t meet the requirements of the field, it will appear notification.

    Then after you change the field value, you need save the form firstly then change tab to trigger js.

    If it still can’t work, you can try to clear cache or use browser privacy mode to test again.

    Also, if you want, you can share your code and screenshot without personal privacy so I can help you better.

  • AdityaTripathi Profile Picture
    AdityaTripathi 5 on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    I have added the onchange events on tab and field still its not working. For clear understanding of my issue you can just Press F12 and write in Console Xrm.Page.getControl("hs_asatdate").setNotification("abc","123") and then change the tab and run this command Xrm.Page.getControl("hs_asatdate").clearNotification("123") it will return true but notification will not be cleared. If you need formcontext syntax debug a js first then you will get form context and then write in console

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamic 365 - Clearing field level notification in JS on different tabs not working!!

    Hi AdityaTripathi,

    I have test with following js code:

    function notification(executionContext) {
        var formContext = executionContext.getFormContext();
    
        var notification1 = formContext.getAttribute("new_notification1").getValue();
        var notification2 = formContext.getAttribute("new_notification3").getValue();
    
        if (notification1 != null)
            formContext.getControl("new_notification1").clearNotification("101");
        else
            formContext.getControl("new_notification1").setNotification("Please enter value", "101");
    
        if (notification2 != null)
            formContext.getControl("new_notification3").clearNotification("102");
        else
            formContext.getControl("new_notification3").setNotification("Please enter value", "102");
    
    }

    And when I set event Handlers, I select fields and tab OnChange event as trigger.

    pastedimage1604474582218v1.png pastedimage1604474587313v2.png

    In the beginning, I set OnSave event as trigger, the notification can’t be cleared though I fill the field.

    So you can try to select OnChange as event as I described above.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans