Using the BR, displays an info message showing today's date when Incident is created critical

kranthi2
Tera Expert

Hi,

Using the BR, displays an info message showing today's date when an Incident is created with a priority set to "Critical."

 

Please hele me out with BR.

 

Thanks

5 REPLIES 5

Viraj Hudlikar
Tera Sage

Hello @kranthi2 

VirajHudlikar_1-1737787096376.png

Under Advanced section tab under script field enter below code:

(function executeRule(current, previous /*null when async*/) {

	// Get today's date
        var today = new GlideDateTime();
        // Display an info message with today's date
        gs.addInfoMessage('Incident created with Critical priority on: ' + today.getDisplayValue());

})(current, previous);


Your output will be as below:

VirajHudlikar_0-1737787062230.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Hi @Juhi Poddar and @Viraj Hudlikar 

 

Thanks for your explanation, it works.

Hello @SreenadhV 

Glad that it helped you.

 

Thank You 

Juhi Poddar 

Juhi Poddar
Kilo Patron

Hello @kranthi2 

To create a Business Rule that displays an info message showing today's date when an Incident is created with a priority set to "Critical," follow these steps:

Configuration:

  1. Name: Display Today's Date on Critical Priority Incident
  2. Table: Incident
  3. When: After Insert
  4. Condition: priority is critical (assuming "1" represents "Critical" priority)
  5. Script:
(function executeRule(current, previous /*null when async*/) {
    // Get today's date in the desired format
    var today = new GlideDateTime();
    var formattedDate = today.getLocalDate().toString(); // Formats it as 'yyyy-MM-dd'

    // Display an info message with today's date
    gs.addInfoMessage("Incident created with Critical priority. Today's date is: " + formattedDate);
})(current, previous);
  • This Business Rule triggers if the Incident's priority is set to "Critical"
  • It uses GlideDateTime to fetch the current date and formats it.
  • The gs.addInfoMessage() function is used to display an info message with today's date in the Incident form.

Once the Incident is created with the Critical priority, the info message will display on the Incident record showing the current date.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar