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.

Advanced Reference Qualifier in Scoped Application for Record Producer not working

Shane J
Tera Guru

I have a need to limit a Record Producer variable (u_visit) by another (u_study).  I have a m2m table between the two which I should be able to use to pull this off as I have before BUT in this case:

  • This is within a scoped app.
  • This is on a Record Producer.

At this point I'm not sure which, or both, are causing this not to work properly.  I have tried a Script Includes both as scoped and Global and neither seems to even be called.  In the Advanced Reference Qualifier I'm using:

javascript: new LimitCSMVisitTypeGlobal.LimitCSMVisitTypeGlobal();

Here's my script:

 

function LimitCSMVisitTypeGlobal() {
   var gp = [];
   var a = current.variables.u_study;
   
   //return everything if the assigned_to value is empty
//    if(!a){
//       return;
//    }
   //Query the M2M table
   var grp = new GlideRecord('sn_customerservice_m2m_csm_visit_types_studies');
   grp.addQuery('u_study',a);
   grp.query();
   while(grp.next()) {
      if (gp.length > 0) {
         //build a comma separated string of groups if there is more than one
         gp += (',' + grp.u_csm_visit_types.toString());
      }
      else {
         gp = grp.u_csm_visit_types.toString();
      }
	
	   
	   
   }
// return Groups where assigned to is in those groups we use IN for lists
   return 'sys_idIN' + gp;
}

As pulled from here:  https://docs.servicenow.com/bundle/kingston-platform-administration/page/script/server-scripting/tas...

 

1 ACCEPTED SOLUTION

Shane J
Tera Guru

With some help from a peer, I had missed the first () when calling the Script Includes.

 

javascript: new LimitCSMVisitTypeGlobal.LimitCSMVisitTypeGlobal();

 

should be:

 

javascript: new LimitCSMVisitTypeGlobal().LimitCSMVisitTypeGlobal();

View solution in original post

2 REPLIES 2

S_C Pressley
Kilo Guru

 

How to: create an advanced reference qualifier for a Record Producer

Try this as a reference! Definitely helped me in this situation as well! Good luck 🙂

Shane J
Tera Guru

With some help from a peer, I had missed the first () when calling the Script Includes.

 

javascript: new LimitCSMVisitTypeGlobal.LimitCSMVisitTypeGlobal();

 

should be:

 

javascript: new LimitCSMVisitTypeGlobal().LimitCSMVisitTypeGlobal();