web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Showing Error message after clearNotification() on field notification

(0) ShareShare
ReportReport
Posted on by 310

Hello Sir,

I have  a date field ,   

when I compare "Est. close date field" with current date in if condition i.e. "Est close date" >= new Date() using Javascript

and set setNotification(msg,type,id) on date field 

it works but after clearNotification(id); still shows error message even after "Est close date" = todays date

3146.opp.png

*This post is locked for comments

I have the same question (0)
  • Sreevalli Profile Picture
    3,264 on at

    Hello Manoj,

    could you share the code snip, that helps in finding the issue

  • Screen one Profile Picture
    310 on at

    okay for est. close date <= new Date()

    function OnChange_EstimatedCloseDate(executionContext) {

       debugger

      // alert("step 1");

       var formContext = executionContext.getFormContext();

       var EstDate = formContext.getAttribute("estimatedclosedate").getValue();

       var today = new Date();

      // alert(EstDate);

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

       if (EstDate <= today)

       {

           formContext.getControl("estimatedclosedate").setNotification("Est. Close date should be greter than or equal to today date");

       }

       else

       {

           formContext.getControl.clearNotification();

    }

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Try with this  , for field notification you can show like this without id -

      Xrm.Page.getControl("new_fieldName").setNotification("Incorrect Bank Account Format.");

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

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Since you are calling the function on onchange event of this field. Make sure you hit TAB after entering the data. the notification should go away.

  • gdas Profile Picture
    50,091 Moderator on at

    Are you sure that your code entering "Else" part? Try to debug please . Also in your code one bracket is missing -

    function OnChange_EstimatedCloseDate(executionContext) {
        debugger;
        // alert("step 1");
        var formContext = executionContext.getFormContext();
        var EstDate = formContext.getAttribute("estimatedclosedate").getValue();
        var today = new Date();
        // alert(EstDate);
        formContext.getControl("estimatedclosedate").clearNotification();
        if (EstDate <= today)
        {
    
            formContext.getControl("estimatedclosedate").setNotification("Est. Close date should be greter than or equal to today date");
        }
        else
        {
      
            formContext.getControl.clearNotification();
        }
    }


  • Screen one Profile Picture
    310 on at

    not working

  • Screen one Profile Picture
    310 on at

    no bracket missing

  • gdas Profile Picture
    50,091 Moderator on at

    My friend , you have to debug yourself.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Uffff you missed to mentioned the control name -

    function OnChange_EstimatedCloseDate(executionContext) {
        debugger;
        // alert("step 1");
        var formContext = executionContext.getFormContext();
        var EstDate = formContext.getAttribute("estimatedclosedate").getValue();
        var today = new Date();
        // alert(EstDate);
        formContext.getControl("estimatedclosedate").clearNotification();
        if (EstDate <= today)
        {
    
            formContext.getControl("estimatedclosedate").setNotification("Est. Close date should be greter than or equal to today date");
        }
        else
        {
      
            formContext.getControl("estimatedclosedate").clearNotification();
        }
    }


  • Suggested answer
    Sreevalli Profile Picture
    3,264 on at

    Hi,

    Little modification to Goutam's code, try with Unique Ids

    function OnChange_EstimatedCloseDate(executionContext) {
        debugger;
        // alert("step 1");
        var formContext = executionContext.getFormContext();
        var EstDate = formContext.getAttribute("estimatedclosedate").getValue();
        var today = new Date();
        // alert(EstDate);
        formContext.getControl("estimatedclosedate").clearNotification("1");
        if (EstDate <= today) {
    
            formContext.getControl("estimatedclosedate").setNotification("Est. Close date should be greter than or equal to today date", "ERROR", "1");
        }
        else {
    
            formContext.getControl("estimatedclosedate").clearNotification("1");
        }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans