When Incident priority been raised Send Notification

bgulshan
Tera Contributor

If Incident Priority was p2 raised to P1

If Incident Priority was p3 raised to P1 or P2

If Incident Priority was p4 raised to P1/P2/P3

If Incident Priority was p5 raised to P1/P2/P3/P4

 

How do I achieve this using notification when to send Advanced scripting condition

 

2 ACCEPTED SOLUTIONS

mohdarbaz
Kilo Guru

Navigate to System Notification > Email > Notifications.
When to send: Choose Updated
Use the Advanced condition to specify when the notification should be sent.
Use the below script.
If the conditions are met, it adds an informational message and returns true, triggering the notification.


// Check if the priority has changed
if (current.priority.changes()) {
// Check if the priority was raised from P2 to P1
if (current.priority == 1 && previous.priority == 2) {
gs.addInfoMessage('Incident priority raised from P2 to P1');
return true;
}
// Check if the priority was raised from P3 to P1 or P2
if ((current.priority == 1 || current.priority == 2) && previous.priority == 3) {
gs.addInfoMessage('Incident priority raised from P3 to P1 or P2');
return true;
}
// Check if the priority was raised from P4 to P1, P2, or P3
if ((current.priority == 1 || current.priority == 2 || current.priority == 3) && previous.priority == 4) {
gs.addInfoMessage('Incident priority raised from P4 to P1, P2, or P3');
return true;
}
// Check if the priority was raised from P5 to P1, P2, P3, or P4
if ((current.priority == 1 || current.priority == 2 || current.priority == 3 || current.priority == 4) && previous.priority == 5) {
gs.addInfoMessage('Incident priority raised from P5 to P1, P2, P3, or P4');
return true;
}
}
return false;

View solution in original post

J Siva
Tera Sage

Hi @bgulshan 
There's no need for an advanced scripting condition. You can simply define the conditions using the condition builder as shown below. This will fulfill your requirement.

 

JSiva_0-1746416346658.png

JSiva_1-1746416422099.png

 

Regards,
Siva

 

View solution in original post

5 REPLIES 5

mohdarbaz
Kilo Guru

Navigate to System Notification > Email > Notifications.
When to send: Choose Updated
Use the Advanced condition to specify when the notification should be sent.
Use the below script.
If the conditions are met, it adds an informational message and returns true, triggering the notification.


// Check if the priority has changed
if (current.priority.changes()) {
// Check if the priority was raised from P2 to P1
if (current.priority == 1 && previous.priority == 2) {
gs.addInfoMessage('Incident priority raised from P2 to P1');
return true;
}
// Check if the priority was raised from P3 to P1 or P2
if ((current.priority == 1 || current.priority == 2) && previous.priority == 3) {
gs.addInfoMessage('Incident priority raised from P3 to P1 or P2');
return true;
}
// Check if the priority was raised from P4 to P1, P2, or P3
if ((current.priority == 1 || current.priority == 2 || current.priority == 3) && previous.priority == 4) {
gs.addInfoMessage('Incident priority raised from P4 to P1, P2, or P3');
return true;
}
// Check if the priority was raised from P5 to P1, P2, P3, or P4
if ((current.priority == 1 || current.priority == 2 || current.priority == 3 || current.priority == 4) && previous.priority == 5) {
gs.addInfoMessage('Incident priority raised from P5 to P1, P2, P3, or P4');
return true;
}
}
return false;

In place of return true, using true and it is working

J Siva
Tera Sage

Hi @bgulshan 
There's no need for an advanced scripting condition. You can simply define the conditions using the condition builder as shown below. This will fulfill your requirement.

 

JSiva_0-1746416346658.png

JSiva_1-1746416422099.png

 

Regards,
Siva

 

Agreed! we can go with condition builder instead of advanced script, optimized for efficient execution, reducing the risk of performance issues. 

If my response helped, please mark it correct and close the thread so that it benefits future readers.