- 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 11:00 PM
Sorry. Actually it worked! There was an issue, the field was marked Mandatory, which was preventing the script from working! Thanks so much for all your help! I will mark your answer as correct.