How to get child records from parent record from api

Chandu Telu
Tera Guru
Tera Guru

Hi All,

I had requirement like   i have an parent table rest api   we want child table records in the same api can we achieve this!!

Thanks

Chandu Telu

3 REPLIES 3

ramireddy
Mega Guru

For "child table" records, you can't do it in same API call. You need to use another API call. What you need is, reference record data, you can achieve using dot-walking in same API call.



Dot-Walking in the REST Table API


Hi ram,



By using dot walking we can get the single record.But i want all child table records





Thanks


Chandu


Hi Chandu,



Generally a parent record will have many child records, in turn they might have many more. So, generally web applications, will not return child records data, while getting record details. For that you need to make another API call. Suppose, once you get an user details, to get his groups, you need to make another API call like below.



For example:


To get details of an user with username "admin"


https://devxxxx.service-now.com/api/now/v1/table/sys_user?sysparm_query=user_name=admin



To get details of an user groups with username "admin", we will take "sys_id" from above call and make another call.



https://devxxx.service-now.com/api/now/v1/table/sys_user_grmember?sysparm_query=user=6816f79cc0a8016...