Monday, March 21, 2022

Form Notification in Model Driven Apps Using JavaScript

Introduction:


In this blog we will see how to show Form Notification using JavaScript in Model Driven Apps.


Scenario:

Consider i have an Account Screen, with Annual Revenue field as 5000, if the value exceed more than 5000 i need to show an Notification.

 

rampprakash_0-1647868347721.png

 

Implementation Steps:

 

1. Create a WebResource 

2. Open the JavaScript (Web Resource which you have Created).

 

Creating WebResource:

 

rampprakash_1-1647869035635.png

 

Adding Web Resource to Form

 

rampprakash_2-1647869115049.png

 

In My Scenario, am triggering alert on Change of Field Value.

 

 So, Open the Form --> Click on the Field --> Click Events --> Then Input the Event name (Function name) and WebResource where the Function residing --> Save --> Publish

 

rampprakash_3-1647869168393.png

 

 

Write the below Code in the JavaScript

 

function onChange(executionContext){
var formContext = executionContext.getFormContext();
if(formContext.getAtrribute("annualrevenue").getValue()>5000){
formContext.ui.setFormNotification("Annual Revenue should be less than 5000", "INFO", "1");
}
else{
formContext.ui.clearFormNotification("1")
}
}

 

Notification Pop-up:

 

rampprakash_4-1647869413150.png

 

No Notification(Because we are Clearing the Notification):

 

rampprakash_5-1647869439486.png

 

 

Once written above code, just save and publish.

 

That's it :slightly_smiling_face:

No comments:

Post a Comment

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...