The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Query a reference field

charanpreet
Kilo Expert

I am trying to query a reference field with function, gr.addQuery('name', current.name); Both name and current name are reference field refeering to non display value. But the record is not getting queried.

10 REPLIES 10

Deepa Srivastav
Kilo Sage

try gr.addQuery('sys_id', current.name); and check the count in the log by giving. gs.log(gr.getRowCount());


Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


I tried with the below code but the record with reference field('assessment_record') is not getting queried.


var gr = new GlideRecord('asmt_m2m_category_assessment');


gr.addQuery('assessment_record', current.vendor);


//gr.addActiveQuery();


gr.query();                        


                                                       
while(gr.next())


{                          
gs.addInfoMessage(gr.assessment_record.getDisplayValue());


                       
gr.deleteRecord();}


Hi Charanpreet,



what is the printed value of the assessment_record? is it a sys_id or a value, upon that you can query the records and can delete them.



Regards,
Suresh D


It is the name of the company (referring to core_company table).