I need to create a BR or Work flow

MoeG82
Tera Contributor

I need to be able to send out emails to the assigned user from the incident table. The assignment group is anything BUT Service Desk and there has been no updated activity to the ticket in 3 days. This will serve as a reminder for them but I am unsure on the script and I have been hearing different ways to accomplish this. Some say a work flow, some says a BR or scheduled job. Any suggestion will do. Thanks

1 ACCEPTED SOLUTION

So you'll need to do two things before the flow if you don't already have these. You'll need to register an Event, then create/set your notification to trigger from your Event. Your overall flow would look like this

ZachKoch_0-1723207907147.png

Your trigger you set to daily and set to whatever time you want it to run

ZachKoch_1-1723207942547.png

You would look up all records with these conditions

ZachKoch_2-1723207995630.png

If you find records

ZachKoch_3-1723208018942.png

Then for each record found

ZachKoch_4-1723208045335.png

Fire your event which will trigger your notification for each record

ZachKoch_5-1723208076768.png

Keep in mind, if you are using Washington or Xanadu, the Fire Event action is out of the box. If you are on anything before Washington, you'll need to create a custom action to fire the event. Please let me know if you have any more questions. This solution requires no coding (unless you have to build the custom action, in which case it takes 1-2 lines of code)

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

View solution in original post

9 REPLIES 9

Sumanth16
Kilo Patron

Hi @MoeG82 ,

 

Create scheduled job which runs daily.

 

try this script below; you will have to iterate over all problem records

that could be a limitation

 

var problem= new GlideRecord('problem');
problem.addActiveQuery();//update your query
problem.query();

while(problem.next()){

var updatedTime = problem.sys_updated_on;

var days = 3;

var dur = new GlideDuration(60*60*24*days*1000);

// paste the sys_id of the 8*5 weekday schedule excluding holidays and weekends

var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); 

var finalTime = schedule.add(updatedTime, dur,'');

var updatedGdt = new GlideDateTime(updatedTime);

var finalTimeGdt = new GlideDateTime(finalTime);

// if the date/time after adding 5 business days is greater than updated time

if(finalTimeGdt > updatedGdt){
gs.eventQueue('my.event', current, gr.assigned_to);
}

}

 

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Thanks & Regards,

Sumanth Meda

Soni Tushar
Tera Guru

Hello @MoeG82 ,

Try with this Scheduled Job --

 

(function executeRule() {
    var gr = new GlideRecord('incident');
    gr.addEncodedQuery('assignment_group!=YOUR_SERVICE_DESK_GROUP_SYS_ID^sys_updated_on<javascript&colon;
gs.daysAgo(3)^active=true');
    gr.query();
    
    while (gr.next()) {
        // Prepare and send email
        var mail = new GlideEmailOutbound();
        mail.setSubject("Reminder: Your Incident Requires Attention");
        mail.setBody("Dear " + gr.assigned_to.name + ",<br><br>Your incident with number " + gr.number +                         " has not been updated for 3 days. Please review and take necessary actions.<br><br>Thank you.");
        mail.setTo(gr.assigned_to.email);
        mail.send();
    }
});

/* Note: Assignment Group Filter: Replace YOUR_SERVICE_DESK_GROUP_SYS_ID with the actual sys_id of the  
   "Service Desk" assignment group. */

 

If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!

Thank you. Which sys ID am I getting? Is it the sys ID from the incident table as a whole? The parameters are any group other than the Service Desk and we have a few of them.

@MoeG82 ,

 

In the GlideRecord query you're using, YOUR_SERVICE_DESK_GROUP_SYS_ID should be replaced with the Sys ID of the Service Desk group you want to exclude from the results. This is the Sys ID of the group from the sys_user_group table, not from the incident table.

 

Query Explanation ---

assignment_group!=YOUR_SERVICE_DESK_GROUP_SYS_ID:  This part of the query selects incidents where the assignment_group is not equal to the specified Service Desk group’s Sys ID.

 

sys_updated_on<javascript&colon;gs.daysAgo(3):  This part selects incidents that were last updated more than 3 days ago.


active=true:  This ensures that only active incidents are considered.

 

If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!

line 4 keeps getting an error:

 

 gs.daysAgo(3) ^ active = true ');