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.

Illegal Access to global script include from scoped app

IndianaJones
Tera Expert

I am trying to use the "group type" filtering on the assignment group for Incidents and Cases. The script include works fine for Incidents but I cannot get it to work for Cases. Does anyone know what I am doing wrong? I saw in a post to not use gs.log so I changed that line to gs.info for scoped applications. The script include shows to be accessible from all application scopes. 

 

Error I am getting on the case table:

IndianaJones_0-1722000248642.png

 

Here is how I am calling the global script include:

IndianaJones_1-1722000277908.png

 

Here is my script include:

IndianaJones_2-1722000299633.png

 

Script include code:

 

//
// this will do a lookup on the group type display values and return
// a query condition that will query on the group type sys_id values
// on entry
//    reference = the table that is being referenced
//    source = the table that contains the reference
//
function GetGroupFilter(types) {
   //
   // By default only use for service_catalog requests
   //
   //if (source != 'sc_request' && source != 'sc_req_item')
   //    return "type=null";

   //
   // turn a non specification into a null request
   //
   if (types == null)
      return "type=null";

   gs.info("GetGroupFilter: Translating '"+types+"' into sys_id values");
   var gt = new GlideRecord("sys_user_group_type");  
   var filters = types.split(",");
   var qc = null;
   for (var i = 0; i < filters.length; i++) {
      if (qc == null)
         qc = gt.addQuery("name", filters[i]);
      else
         qc.addOrCondition("name", filters[i]);
   }
   var gtr = new GlideRecord("sys_user_group");
   gt.query();
   qc = null;
   while (gt.next()) {
      if (qc == null)
         qc = gtr.addQuery("type", gt.sys_id);
      else
         qc.addOrCondition("type", "CONTAINS", gt.sys_id);
     
   }
   return qc;
}

 

 

 

 

1 REPLY 1

onwork1948
Giga Contributor

When working with ServiceNow scoped applications, accessing a global script include from within a scoped app directly is restricted to ensure encapsulation and security.