I have 2 doctypes, Agency and Category. Agency has field that linked to Category, meanwhile Category is a standalone. I need to fetch data in Agency along with category_name, not just the name/id. This is what I’ve tried:
{{erpnext.url}}/api/resource/Agency?fields=[“name”,“profile_img”,“fullname”,“tabCategory
.category”,“position”]&filters=[[“category”,“=”,“f9c3093c05”]]
This works if Category is child of Agency. But I need Category to be a standalone. Is this possible?
NCP
April 28, 2022, 8:01am
2
Hi @hikmahaz ,
I think is not possible if the Category is not linked with Agency because of how could to get a record without any link.
Thanks.
so if Category is not a child doctype it’s not possible? ok, thanks
NCP
April 28, 2022, 8:04am
4
Because it’s not connected to each other.
Thanks.
but Agency has a field that linked to Category tho. that alone is not enough?
NCP
April 28, 2022, 8:09am
6
Category field in parent doctype of Agency or child doctype of Agency?
If a link in the child doctype of the Agency then the name of the child table?
Maybe, if possible then there is more complexity to get data.
Thanks.
Agency: agency_name (data), address (text), category (link to Category)
Category: category_name (data), priority (int)
those were the fields on each doctype
NCP
April 28, 2022, 8:53am
8
Hi @hikmahaz ,
{{erpnext.url}}/api/resource/Agency?fields=["category"]&filters=[["category","=","f9c3093c05"]]
only category id display only.
Otherwise, first, fetch category_name and priority from Category in a custom field in Agency Doctype then API set like
{{erpnext.url}}/api/resource/Agency?fields=["category_name"]&filters=[["category_name","=","Test1"]]
Thanks.