How do I get "Related items" through API?
Hi there,
Since there's no automatic 2-way sync for custom relationship fields (see https://help.podio.com/hc/communities/public/questions/203783936-No-two-way-sync-for-relationship-fields-) I wanted to get all related items in an app item through the api, so that I can list them in a dashboard I created. But since this field is "hard coded" in every app and not a custom field I don't know how to access it. I found a few hints in the community here and there but nothing solid. To give you the full picture: I have a projects app and a deliverables app. On my dashboard I want to show the project titles and below that all the linked deliverables.
Hope you can help.
Regards,
Alex
-
Hey Alex,
There are 2 ways to do it, and it depends mostly on which way the relationship goes.
1. You can use the Filter Items call (Link: https://developers.podio.com/doc/items/filter-items-4496747) to filter the app with the relationship field by the item ID of the related item. The problem with this is the "Filter Items" call is limited, and I has a reduced amount of calls you can do to it (~200 I believe). If you're going to be using this heavily then,
2. Use the get item call (Link: https://developers.podio.com/doc/items/get-item-22360)
You will want to get the item with the relationship field in it. That will give you all of the id's for all of the items in that relationship field. If you want you could then loop over those IDs and get each of those items, but you can just drop that list of IDs into a relationship field and it will work. -
Hi Ammon,
Thanks for pointing me in the right direction. I hadn't thought of going the other way round through my deliverables and check for the reference from that side. Guess I was just to lazy :-) But I think it's easier for me to get this 2-way sync working, which would solve my initial problem. I'm quite knowledgeable with API reading but haven't done any writing. I can't even get this simple example from the docs to work:
$item = PodioItem::get_basic(238823234);
$field_id = 'reference';$item->fields[$field_id]->values = new PodioItem(array('item_id' => 238823567));
It simply doesn't do anything. Not even an error. Anyway, still a long way to go, but it's definitely worth it!
Thanks,
Alex
Please sign in to leave a comment.
Comments
5 comments