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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Form Notification - Show and Clear

(0) ShareShare
ReportReport
Posted on by 123
Hi,
 
I am trying to add a form level notification to show a message, and when a field is marked to Yes (two option), the notification clears.
 
This piece of script work to show the notification.
 
function FormNotificationInfo(executionContext) {
        var formContext = executionContext.getFormContext();
        var infoMessage = /This is Warning Notification./
        var infoId = Math.random().toString();
        //information notification
        formContext.ui.setFormNotification(infoMessage, /WARNING/, infoId);
        }
 
So I wrote something like this but it doesn't seem to work.
 
function FormNotificationInfo() {
    
        var value = Xrm.Page.getAttribute(/sandm_shownotification/).getValue();
        var infoMessage = /This is Warning Notification./
        
        if(value == 1){
       //clear error notification
       formContext.ui.clearFormNotification(888);
        }
        if(value == 0){
        //information notification
        formContext.ui.setFormNotification(infoMessage, /WARNING/, 888);
        }
        
}
 
Can someone help please. I not the best at writing scripts.
 
Thanks
Damesh
I have the same question (0)
  • Suggested answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Hi Damesh,
    1.In your second code, you are missing the execution context and getFormContext that you used in the first code.
    2.Uisng this syntax to get value from the notification field.
    formContext.getAttribute(arg).getValue()
     
    Please refer to the following code:
    function FormNotificationInfo(executionContext) {
        var formContext = executionContext.getFormContext();
        var value = formContext.getAttribute("cre80_shownotification").getValue();
        var infoMessage = "This is Warning Notification.";
    
        if (value == 1)// field label is No
        {
            //clear error notification
            formContext.ui.clearFormNotification(888);
        }
        if (value == 0)// field label is Yes
        {
            //information notification
            formContext.ui.setFormNotification(infoMessage, "WARNING", 888);
        }
    }
     
    My notification field:

    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    Regards,
    Leah
     

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans