How do I get "Related items" through API?

Comments

5 comments

  • Ammon Tapusoa

    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.

    0
    Comment actions Permalink
  • Ammon Tapusoa

    Sidenote: if you are wanting to create a 2-way sync, and are knowledgeable in the API that is also very possible. This is something that we have set up for plenty of clients, and isn't too complicated.

    0
    Comment actions Permalink
  • Alex Burkhardt

    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

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi Alex,

    You need to call $item->save() to send your changes back to Podio. Otherwise all you have done is modify a local PHP object.

    /Andreas

    0
    Comment actions Permalink
  • Alex Burkhardt

    Now that was pretty obvious. Thanks Andreas!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk