Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send notification to assignee if incident is in active state for 10 days

harry24
Tera Contributor

Hello , 

I want to Send notification to assignee if incident is in active state for 10 days 

 

Thanks 

5 REPLIES 5

VaishnaviShinde
Kilo Sage

Hello @harry24 ,

 

Try the below code

 

var incident = new GlideRecord('incident');
incident.addActiveQuery();
incident.query();
while(incident.next()){
    var dueDate = new GlideDateTime(incident.opened_at);
    var gdt =  new GlideDateTime();
    var currentDate = gdt.getLocalDate();
    var dateDiff =new GlideDateTime.subtract(dueDate, currentDate);
    var days= dateDiff.getDayPart()
    gs.info(days);
    if(days >= 10){
        gs.eventQueue('your evnt name',incident);
    }
}

 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde