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

I was looking into the asmt_m2m_category_assessment and it's field "assessment_record" point to the table "asmt_assessable_record". As I understand you, current.vendor point to core_company. Here you will never get a match if you use "gr.addQuery('assessment_record', current.vendor)"



//Göran


Suresh1
Tera Guru

Try to get that value in a separate variable and query then. because reference fields cannot be queried directly.



Something like:


var temp= gr.getValue('field_name');


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



Regards,
Suresh D


I tried with above code, all the records of table are getting queried irrespective of the current.vendor value.


charanpreet
Kilo Expert

We can use dot operator to refer the particular field of the table being referred.


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


Thank you Charanpreet,



The dot walking method worked fine for me. It is (one of?) the correct answer.