- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 01:36 AM
Hello,
I'm trying to query a relationship table through the REST API but I want to get the results only for a subset of parent records.
Some of the filter that I applied on parameters like sys_class_name worked but others that are based on custom fields do not appear to be working for any values.
The query I'm using looks like the one below.
/api/now/table/<relationship table>?sysparm_display_value=true&sysparm_limit=50&sysparm_exclude_reference_link=true&sysparm_query=parent.sys_class_name=<Parent class name>^type=<type of relationship>^parent.<custom_field>LIKE<filter value>
The first two filters on the sys_class_name and type work as expected but the third one that's based on a custom field doesn't work.
Is there a way to make this work? The only other option I see right now is make multiple calls, one to the parent table and then filter the relationship table on the basis of results received from there.
Thanks,
Karan
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 04:52 AM
Chances are that the parent reference field refers to a table that does not have the field you are using in your query.
In this case, you can use this syntax instead:
parent.ref_<table name>.u_<field name>
You need to contact the servicenow administrators to make sure of that.
HTH
Sylvain

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 02:09 AM
Hi Karan,
I'm wondering, is your custom field attached to the table used as the reference? Or is it attached to a table that was extended from it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 03:05 AM
Hi Syvo,
I'm not really sure what the difference is between the two is or how to find that out.
Is there a way I can find this, preferably with details that I can get through the REST API as I don't really have enough access to do much else at this point. All I'm trying to do is extract that data so I can use it in my program.
If I query the parent table directly though, I do see the custom field I need in there.
Thanks,
Karan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 04:52 AM
Chances are that the parent reference field refers to a table that does not have the field you are using in your query.
In this case, you can use this syntax instead:
parent.ref_<table name>.u_<field name>
You need to contact the servicenow administrators to make sure of that.
HTH
Sylvain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 06:29 AM
Hi Sylvain,
That worked perfectly!
Thank you.
Karan