The CreatorCon Call for Content is officially open! Get started here.

Reference Qualifier to hide a field

paradise624
Tera Contributor

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?

1 ACCEPTED SOLUTION

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

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

View solution in original post

15 REPLIES 15

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.