- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 05:51 AM
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...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 08:09 AM
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();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 06:11 AM
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 08:09 AM
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();