Dynamics 365 Form Notifications

Dynamics 365 Form Notifications

Forms in Dynamics 365 provide end-users with a clear and structured method for which to input data.  Tabs, sections, and even embedded forms (i.e., a form within a form) give customizers a nearly endless range of configuration options to work with when designing and implementing a form structure that fits a client’s needs.  Sometimes, though, it becomes necessary to display a notification to an end-user on a form when a particular condition is met.  In these cases, custom JavaScript can be leveraged to display different types of notifications, such as errors, warnings, and general information.

Note that form notifications differ from in-app notifications, which Beringer has written about here.

Basic form notification JavaScript file

To display a simple form notification, we can use the following JavaScript code:

Essentially, this code will get the current form context and monitor the name column on the form for any changes; this is done within the testNotification function.  If the value in the name column changes, the name_change function will run, which holds our three sample notifications, each of a different level (WARNING, ERROR, and INFO).  Depending on the level, we will see a different notification icon when displayed:

Setting up our form to accept form notifications

Once we have our .js file, we need to set up the form in Power Apps to accept it.  Navigate to the form in the Power Apps form editor, then add a new Library.  Create a new Web Resource file and upload the .js file.  Provide a display and schema name, then ensure the type is set to JavaScript (JS).  Then, locate our new Web Resource and add it to the Library.

Once the above steps are complete, we need to tell Power Apps to load the Library each time the form is loaded by an end-user.  Within the form properties, select the Events tab, expand On Load, then add a new Event Handler.  Set Event Type to On Load, Library to the Web Resource you created, and Function to the name of the function on line 1 of your JavaScript file.  Ensure that Enabled and Pass execution context as first parameter are both checked, then click Done.  Save and publish your form, then fully refresh your browser.

Contact Beringer Today!

We love to implement Microsoft Dynamics 365 and Power Platform functionality here at Beringer.  We’ve been working with Microsoft Dynamics since its inception, and we’re always finding innovative ways to implement the latest tools and help automate business processes.

Beringer Technology Group, a leading Microsoft Gold Certified Partner specializing in Microsoft Dynamics 365 and CRM for Distribution also provides expert Managed IT ServicesBackup and Disaster RecoveryCloud Based Computing, Email Security Implementation and TrainingUnified Communication Solutions, and Cybersecurity Risk Assessment.