Related lists query

rody-bjerke
Giga Guru

Hi,

I've got a table, lets call it Shops and on the table Shops there is a field for ShopID which is the shops unique ID. The field db name is u_shopid.

Then I have another table, lets call it Asset which includes the assets for the shop. On this table there is also a ShopID that is the shops unique ID. The field db name is u_shopid.

Then i created a Relationship for these two tables.

And the query is:

(function refineQuery(current, parent) {

// Add your code here, such as current.addQuery(field, value);

})('u_shopid', parent.u_shopid);

And the result I want is that when i go into the Shops table, I will see the related lists with the assets for this shop. So I add the relationship i created as a related lists to the shop form.

But somehow I can't get the related list to show the assets for that spesific shop that i see on the screen when i'm in the form.

What am I doing wrong

Best regards,

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Rody,



Replace your code with this.



(function refineQuery(current, parent) {




current.addQuery('u_shopid', parent.sys_id);




})(current, parent);


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Rody,



Replace your code with this.



(function refineQuery(current, parent) {




current.addQuery('u_shopid', parent.sys_id);




})(current, parent);


Hi Pradeep,



That worked, thanks. Now I know alot about related lists



Best regards,


Excellent!



Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you


srinivasthelu
Tera Guru

Hi Rody,



Pradeep   should work, In case if it does not, I presume that might be because the shop_id field is not a reference field on your Asset table so, something like below should work



(function refineQuery(current, parent) {




current.addQuery('u_shopid', parent.u_shopid);




})(current, parent);