web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Showing Error message after clearNotification() on field notification

    You may have to disable legacy form rendering, have a look at this link

    community.dynamics.com/.../243866

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at
    RE: Showing Error message after clearNotification() on field notification

    Hi Manoj,

    check if there are any other scripts or Business rules for validation?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Showing Error message after clearNotification() on field notification

    I dont believe below code is not working , just to make sure that you are calling the method in onchange of the field. I executed below code and its working fine .

    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();
        }
    }
    


    7382.2019_2D00_03_2D00_07_5F00_19_2D00_01_2D00_42.jpg

    7382.2019_2D00_03_2D00_07_5F00_19_2D00_01_2D00_42.jpg

  • Screen one Profile Picture
    310 on at
    RE: Showing Error message after clearNotification() on field notification

    still showing error

  • Screen one Profile Picture
    310 on at
    RE: Showing Error message after clearNotification() on field notification

    not works

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at
    RE: Showing Error message after clearNotification() on field notification

    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");
        }
    }
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Showing Error message after clearNotification() on field notification

    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();
        }
    }


  • gdas Profile Picture
    50,091 Moderator on at
    RE: Showing Error message after clearNotification() on field notification

    My friend , you have to debug yourself.

  • Screen one Profile Picture
    310 on at
    RE: Showing Error message after clearNotification() on field notification

    no bracket missing

  • Screen one Profile Picture
    310 on at
    RE: Showing Error message after clearNotification() on field notification

    not working

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans