Repeat incidents

Brian Lancaster
Tera Sage

On our record producer for Incidents we have a reference field where a user can choose from their closed incidents.   It is using an advanced reference qualifier that is showing as javascript:getCallerClosedIncidents().   This was not working and was showing users all incidents in the system.   I went to script includes and could not find getCallerClosedIncidents.   I'm trying to recreate it but I'm not 100% sure how to write the script so the reference only pulls the current callers closed incidents.   Anybody have something similar?

1 ACCEPTED SOLUTION

If you want to do it base on the caller field on the form you cannot use is dynamic me as that will be the logged in user.  You will have to do it with an advanced reference qualifier.

javascript:'caller_id=' + current.variables.caller_id +'^stateIN6,7'

find_real_file.png

View solution in original post

22 REPLIES 22

Mike Allen
Mega Sage

You could do a Script Include like this:



function getCallerClosedIncidents(){


  var answer = '';


  var incident = new GlideRecord('incident');


  incident.addQuery('caller_id', gs.getUserID());


  incident.addQuery('active', false);


  incident.query();


  while(incident.next()){


  var incList = (incList == '')? incList.sys_id : ',' + incList.sys_id;


  answer = 'sys_idIN' + incList;


  }


  return answer;


}


Capture.PNG


This is returning no incidents when I try my account.   If I'm in as my admin it returns all incidents.   Also we have a caller_id (displayed as open on behalf of) which is a reference to the sys_user table.   I would like to use this filed so if they change the caller to someone else it will bring up that persons incidents.   I tried changing gs.getUserID() to current.caller_id but that returns all incidents as well.


This is strange as soon as I closed out an incident created with my admin account and close it I get not results leaving the script as you gave it to me.