Skip to main content

Notifications

Announcements

No record found.

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

  • 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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans