search for requested for

Jim Sheldon
Tera Contributor

Trying to find all requests for a specified user. Then creating tasks based on those requests.  Getting error 

Evaluator: com.glide.script.RhinoEcmaError: Cannot read property "requested_for" from null
   script : Line(4) column(0)
      1: var applications = [];
      2: 
      3: var gr = new GlideRecord('sc_req_item'); //Indicate the table to query from
==>   4: gr.addQuery('Request.Requested_for', current.requested_for);
      5: gr.query(); //Execute the query
      6: while (gr.next()) {
      7:     applications.push(gr.short_description.toString());

 running script the first part is below

var applications = [];

var gr = new GlideRecord('sc_req_item'); //Indicate the table to query from
gr.addQuery('Request.Requested_for', current.requested_for);
gr.query(); //Execute the query
while (gr.next()) {
applications.push(gr.short_description.toString());
}

var applicationAA = [];
var applicationSS = [];
var applicationBI = [];
var applicationAB = [];
var applicationCA = [];

for (var i = 0; i < applications.length; i++) {
if (applications[i] == 'APCC Access'

 

what are we missing?

6 REPLIES 6

Jim Sheldon
Tera Contributor

We have a form for decommissioning users. The script is part of the workflow used to pull all the requests for the "current" user (one selected in the form) and have tasks created to remove them from all access granted by the listed requests. Mainly application access. 

Hi @Jim Sheldon 

Please see my reply above where I give a bit more insight into what we're talking about in terms of "current".

What...is your "current" object? A request item record? A request record? Another record?

Whatever it is...it needs actually have a "requested_for" field on it to use it.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!