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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Can we default notifications (setFormNotification) to expand

(0) ShareShare
ReportReport
Posted on by

Hi,

The notifications on a CRM form is important to us.

Sometime there are 4 notifications (Warnings), but they are all collapsed. Once the user clicks on the notification at the top, they expand and all 4 are visible. Below is the code we use:

                   ClientApi.FormContext(executionContext).ui.setFormNotification("This record requires a mobile number", "WARNING", "new_mobile_notification");

Is there a way to write some OnLoad jScript that will default the notifications to be expanded, instead of being collapsed. We don't want the users to miss out on the important warnings.

Many thanks,

gideon

I have the same question (0)
  • Verified answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi gideon,

    Unfortunately, this is not possible.

    Good Luck !

  • Verified answer
    Timothy Bohte Profile Picture
    44 on at

    Hi Gideon,

    I'm afraid that's not possible. Microsoft changed those notifications since version 9 to be less intrusive. You need to think workarounds here.

    You could change the notification type from Warning to Error or change this field mandatory by JavaScript. Then the user can't save the record and in the last case it will show an error also besides the field as well.

    Another workaround is creating your own pop up window. Find more info from Microsoft here: docs.microsoft.com/.../openWebResource

  • Community Member Profile Picture
    on at

    Hi Mehdi & Timothy,

    Thank you very much for your responses and confirming my doubts. I might have to look at workaround.

    Many thanks,

    gideon

  • Suggested answer
    jork Profile Picture
    12 on at

    Hi Gideon,

    I did find one VERY unsupported approach to auto-expanding setFormNotification notifications. You can override the Xrm.Page.ui.setFormNotification function to do some additional DOM manipulation after an alert is called. The below example currently works in a sandbox environment I have access to. The element selectors can probably be fiddled with, but can also hypothetically change whenever Microsoft makes changes:

    // Override Xrm.Page.ui.setFormNotification
    Xrm.Page.ui.setFormNotification = (function () {
    	var cached_function = Xrm.Page.ui.setFormNotification;
    
    	return function () {
    		var result = cached_function.apply(this, arguments); // use .apply() to call it
    
    		setTimeout(function () {
    			var notificationWrapperMessage = parent.document.querySelector("[data-id='notificationWrapper_message']");
    			if (notificationWrapperMessage !== undefined && notificationWrapperMessage !== null) {
    				var notificationWrappers = parent.document.querySelectorAll("[data-id='notificationWrapper']");
    				if (notificationWrappers !== undefined && notificationWrappers !== null) {
    					var expandBanner = false;
    					for (var i = 0; i < notificationWrappers.length; i  ) {
    						var ariaExpanded = notificationWrappers[i].getAttribute('aria-expanded');
    						if (ariaExpanded !== undefined && ariaExpanded !== null && ariaExpanded === "false") {
    							expandBanner = true;
    						}
    					}
    
    					if (expandBanner) {
    						notificationWrapperMessage.click();
    					}
    				}
    			}
    		}, 100);
    		
    		return result;
    	};
    })();

    One additional note: setTimeout is being utilized so that the DOM manipulation happens AFTER the notification is generated. Hope this is helpful to someone out there.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans