Business rule to trigger event for when case is opened and case is resolved, to send notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 01:28 AM
Hi,
We are currently working with notifications, templates, etc. And working on when a case is commented it sends a notification, when a case is opened it sends a notification and when a case is resolved it sends a notificaiton.
To ensure we only have 1 notification and 1 template instead of 1 for each case types we are triggering by event on the notification.
So:
We have created 3 separate event registries, 3 separate notifications and 3 separate notification templates.
1 for when a comment has been added to a case
1 for when a Case is Opened
1 for when a Case is Resolved
We are now currently working on the business rule.
Please see screenshot for when a comment is added to a case.
Can anybody please provide support or guidance on the script that can be added in the advanced tab for when a case is opened or when a case is resolved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 01:38 AM
Hi @Daniel R2
You need to write through conditions
if(current.state.changesTo("open")){
//Trigger the event
}
else if(current.state.changesTo("Resolved")){
//Trigger the event
}
else if(){ //set the proper cnodition
//Trigger the event
}
else{
return false;}
Let me know if you need more help on this.
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 01:38 AM
Hi @Daniel R2,
Take a look at sample scripts and modify it accordingly-
if (current.operation() != 'insert' && current.comments.changes()) {
if (!isConnect())
gs.eventQueue("hr.case.commented", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'insert') {
gs.eventQueue("hr.case.opened", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'update'&& !current.cs_state == "6") // case state is resolved (6) {
gs.eventQueue("hr.case.updated", current, gs.getUserID(), gs.getUserName());
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 01:48 AM
Hello @Daniel R2 ,
Please check the below code and debug and modify according
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.operation=="insert" && current.state=='open')
{
gs.eventQueue('incident.updated', current, gs.getUserID(), gs.getUserName()); // Expamle your event name and parameter
}
else if(current.operation=='update' && current.state=='resolved')
{
gs.eventQueue('incident.updated', current, gs.getUserID(), gs.getUserName()); // Expamle your event name and parameter
}
else if(current.opearation=='update' && current.comments.changes())
{
gs.eventQueue('incident.updated', current, gs.getUserID(), gs.getUserName()); // Expamle your event name and parameter
}
})(current, previous);