Awaiting User Info state and automatically changing to resolved state

Dr_Bruce
Kilo Expert

Notes on Auto Resolve when in Awaiting User Info state


What we wanted: when in the Awaiting User Info state, the user is prompted for a reply after 3 days, and if no response after a further 2 days, the call is moved into the Resolved state.

There's been a number of other posts about this that haven't really worked for us, the sticking point was the auto resolve scheduled job section as the automatic notification of 'hey you, respond to us' reset the counter so nothing ever got to 5 days and was resolved.

Our solution, which works (at least for us), uses the SN metrics rather than the sys_updatedon field that other community posts have suggested.


Other community posts about this:

https://community.servicenow.com/message/707797#707797

https://community.servicenow.com/message/671415#671415

https://community.servicenow.com/message/669062#669062



1.Business Rule for moving from state4 (Awaiting User Info) to state=1 (in progress) if a response is received.

2. Set up an Inactivity Monitor

inactivity monitor: http://wiki.servicenow.com/index.php?title=Setting_Inactivity_Monitors


This counts the number of days a call hasn't been updated.

3. Set up a notification

We set this to just send to the Caller.

4. Scheduled job to resolve if no response

This uses the built in metrics: and is set to run at 1am each morning. http://wiki.servicenow.com/index.php?title=Metric_Definition_Support

var ps = 5;

var pn = parseInt(ps);


if (pn > 0) {

  var inc = new GlideRecord('incident');

  // Change all Awaiting User Info(4) incidents to Resolved(6)

  inc.addQuery('incident_state', 4);

    while (inc.next()) {

    var updated = "";

    var metric = new GlideRecord("metric_instance");

    metric.addQuery('definition', '35f2b283c0a808ae000b7132cd0a4f55'); // Incident State Duration metric

    metric.addQuery('id', inc.sys_id);

    metric.addQuery('value', 'Awaiting User Info');

    metric.orderByDesc('start');

    metric.query();

   

    if (metric.next()) {

      updated = metric.start;

    }

      if (updated != "" && updated < gs.daysAgoStart(pn)) {

    inc.incident_state=6;

      inc.comments = 'Incident automatically Resolved after ' + pn + ' days in Awaiting User Info state.';

      inc.work_notes = 'Incident automatically Resolved after ' + pn + ' days in Awaiting User Info state.';

      inc.u_resolve_codes='Business Systems';

      inc.u_resolve_code_2='ServiceNow';

      inc.u_resolve_notes='Closed awaiting user response.';

      inc.update();

    }

  }

}



9 REPLIES 9

Prabeen can you explain your solution. I have tried the one documented here but it is not working for me. Also does you solution take into account schedule? If a caller submits an incident which has a state change to 4 on Thursday will it be resolved on Sunday? Any help is appreciated as this is becoming high priority for me


Sorry Stephen i was involved in a big project and didn't see your thread. Do you still need help on this?


Thank you Prabeen I was able to resolve this


Hi All.




Im looking to have this in my instance but it does not seem to work.


Step 1 works fine   - Calls return to Active when the users updates the call.


Step 2 - I have created the following Inactivity Monitor below:-



I have put 30 mins as I dont want to be sat around waiting (this is just for testing it will be really 5 working days)



find_real_file.png


Step 3 - I have created a Scheduled job to resolve if no response after 30 mins (this is just for testing it will be really 5 working days)



find_real_file.png



This is the script



var ps = 5;


var pn = parseInt(ps);




if (pn > 0) {


  var inc = new GlideRecord('incident');


  // Change all Awaiting User Info(4) incidents to Resolved(6)


  inc.query('incident_state', 4);


      while (inc.next()) {


      var updated = "";


      var metric = new GlideRecord("metric_instance");


      metric.addQuery('definition', '35f2b283c0a808ae000b7132cd0a4f55'); // Incident State Duration metric


      metric.addQuery('id', inc.sys_id);


      metric.addQuery('value', 'Awaiting User Info');


      metric.orderByDesc('start');


      metric.query();


   


      if (metric.next()) {


          updated = metric.start;


      }


          if (updated != "" && updated < gs.daysAgoStart(pn)) {


      inc.incident_state=6;


          inc.comments = 'Incident automatically Resolved after ' + pn + ' days in Awaiting User Info state.';


          inc.work_notes = 'Incident automatically Resolved after ' + pn + ' days in Awaiting User Info state.';


          inc.close_code ='Solved (Permanently)';


          inc.close_notes ='Closed awaiting user response.';


          inc.update();


      }


  }


}




This doesnt seem to work any ideas as I have calls on the awaiting user info state for more than 30 mins



Thanks


marwel
Tera Contributor

We can use Schedule Job which will run a script.


Script below will

  • find records matching specific condition in this case records in state 2,
  • check difference between actual time and update time
  • update records in this case will change state to 8
var pn =30; // numbers of days

var gr = new GlideRecord('table_name');

gr.addQuery('state', 2);   // anything you are looking for can be encoded query

gr.query();

while (gr.next()) {

var dif = gs.calDateDiff(gs.nowDateTime(), gr.sys_updated_on, true); // true in this case means use seconds , it is checking difference between actual time and time when record was updated

if (dif >= pn * 86400) {     //86400 seconds  = 24 hours

gr.state = 8; // in this case set state to Cancel

gr.active = false;

gr.autoSysFields(false);


gr.update();

}
}


I hope this will be use full I took inspiration from this article https://servicenowguru.com/scripting/business-rules-scripting/calendar-based-incident-autoclose/