cancel
Showing results for 
Search instead for 
Did you mean: 
rampprakash

Form Notification in Model Driven Apps Using JavaScript

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 🙂

Comments

Awesome post! Thanks for sharing!

Do you know how to automatically recalculate rollup fields using Javascript? (Instead of having to manually click the "recalculate" button).

Thanks!

Hello @DanielAmico 

 

We need to write Either Plugin or JavaScript to update it dynamically

Thanks @rampprakash 

Do you have a blog post or video to share?

On how to do that using Plugin or JavaScript?

Thank you!