- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 08:06 PM
I have a requirement to hide a field based on a field on another table.
For example, if field A on table A = false, hide field b on table b.
So I'm using a reference qualifier to make this field B dependent on Field A. I completed the following fields in the Reference Specification tab
For the reference: I selected the table A
For the reference qualifier I used :"simple"
For the reference qualifier condition: I used the condition: If the field A is true
Field A is True
For some reason this does not hide b on table b. Why is this reference qualifier not working?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 09:10 PM
You missed current record filter like from table B you should first get record which is referenced in Table A record.
e.g.
var gr = new GlideRecord('Table A');
gr.addQuery("sys_id",current.table_a_reference_field_name);//this field name should be on Table B form
gr.addEncodedQuery('FIELD A',true);
gr.setLimit(1);
gr.query();
if(gr.hasNext())
{
g_scratchpad.makeVisible = true;
}
else
{
g_scratchpad.makeVisible = false;
}
All other part of the script looks good to me.
Try printing message in BR and see what value it is setting
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 08:51 PM
Hello,
The purpose of Reference Qualifier is to create filters that restrict the data that is returned for a reference field. It is not to be used for hiding the data. You can use UI policy or Client script, in this case, to hide the field with g_form.setVisible or setDisplay.
Hope this clarifies.
Regards,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 08:54 PM
Hi,
Hiding field through reference qualifier doesn't work as far as I know, you should try this with either UI policy or on Load client script.
If you want this to be implemented onload of the form then you could use Display BR to get checkbox value and store in scratchpad object and access the same on load client script and hide or show field.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 09:00 PM
so I wrote this business rule along with this client script on the table where I need to hide the field (b), but its not working. any idea as to what I'm doing wrong here?
Business Rule
var gr = new GlideRecord('Table A');
gr.addEncodedQuery('FIELD A',true);
gr.setLimit(1);
gr.query();
if(gr.hasNext())
{
g_scratchpad.makeVisible = true;
}
else
{
g_scratchpad.makeVisible = false;
}
Client Script
function onLoad() {
var isVisible = g_scratchpad.makeVisible;
g_form.setDisplay("Field B", isVisible);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 09:06 PM
Hello,
Try the below
var gr = new GlideRecord('Table A');
gr.addEncodedQuery('FIELD A',true);
gr.setLimit(1);
gr.query();
if(gr.next())
{
g_scratchpad.makeVisible = true;
}
else
{
g_scratchpad.makeVisible = false;
}