- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 08:27 AM
All,
I need to use a checkbox (true/false) to toggle whether or not I can see inactive users, on a single lonely user reference field. The business has asked that admins (who by default can see inactive users) need to click a checkbox, before they can see inactive users (on just this one form). This is to help with human error, admins are allowed to see inactive users by default, but we want them to have to click a "show inactive users" checkbox first, to prevent accidental picking of inactive.
I've added a checkbox to the form called 'u_show_inactive' and I've written a script include, which I'm trying to call from the on the user reference qualifier. I know the reference qualifier works, because when enter the static value "active=true," I get the desired results (admins can't see inactive). When I blank the reference qualifier, also desired result (admins can see inactive).
What I'm struggling with is calling a script include in place of the static "active = true" that makes this conditional. I want the script include to check current.u_show_inactive, and base my reference qualifier pre-filter on whether or not that checkbox is true. So if the checkbox is true, return no filter. If false, return "active=true" filter. Logically, it all makes sense - but in practice, I can't get the script include to execute correctly.
Any direction would help a bunch!
Reference Qualifier on dictionary override:
javascript:new global.UserCheck.showInactive(current);
So I'm expecting that user reference field to have a prefilter based on what's returned from this script include:
Script Include:
var UserCheck = function() {
return {
showInactive : showInactive,
type : 'UserCheck'
};
function showInactive(current) {
//if false, return active filter
if (!current.u_show_termed) {
return 'active=true';
}
//if true, no filter returned
return;
}
};
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 08:32 AM
You're on the right track Brad. You may be running in to issues with the format of the script include and the null return result when the checkbox is checked. I also try to avoid using 'current' in script includes as it can lead to variable scope issues. I renamed it 'gr'. Try this for the script include instead:
var UserCheck = Class.create();
UserCheck.prototype = {
initialize: function() {
},
function showInactive(gr) {
//if false, return active filter
if (!gr.u_show_termed) {
return 'active=true';
}
//if true, no filter returned
return ''; // send empty string (not null)
},
type: 'UserCheck'
};
Then call it like this:
javascript:new UserCheck().showInactive(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 08:32 AM
You're on the right track Brad. You may be running in to issues with the format of the script include and the null return result when the checkbox is checked. I also try to avoid using 'current' in script includes as it can lead to variable scope issues. I renamed it 'gr'. Try this for the script include instead:
var UserCheck = Class.create();
UserCheck.prototype = {
initialize: function() {
},
function showInactive(gr) {
//if false, return active filter
if (!gr.u_show_termed) {
return 'active=true';
}
//if true, no filter returned
return ''; // send empty string (not null)
},
type: 'UserCheck'
};
Then call it like this:
javascript:new UserCheck().showInactive(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 11:00 AM
Chuck,
That was definitely it! Good call on returning the empty string, I should've known better.
Thanks,
-Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2016 12:24 PM
You are welcome. Glad you got it fixed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2020 07:34 PM
Hi
Here's my understanding or misunderstanding for you to correct me please -
The record which invokes the script include will be the returned to the 'current' object. For example if the script include is called by a dictionary entry on the incident table - current on the script include then refer to the incident table. So, where does a scope issue arise here?
One more question - the variable 'gr' doesn't seem to be declared anywhere here. Is it a global variable?