0

To make my Podio system perfect, I need items to be created automatically based on when another item is created.

My layout: So I have a "Main" app, a "Copy" app, a "Translations" app and a "Links" app. Each one is a different deliverable from a different team, and would be immensely useful to be split up in this way.

Case example: When a user creates a new "Main" item, a "Copy", "Translations", "Links" items are created automatically and are referenced in my "Main" item.

I have the items being created just fine - but it's the references that I'm stuck on!

I believe I need to grab the response from PodioItem::create and save the created item_id as the reference on my "Main" item.

How would this be possible?

I should mention that my PHP is triggered as a hook within podio - on item.create of my Main app.

Full PHP code pasted here: http://pastebin.com/S7NR72tH

Kobius
  • 674
  • 7
  • 28

1 Answers1

2

There's a bit of a tutorial here: https://developers.podio.com/examples/items

The App Reference field just takes an array of item_ids as it's value so you can do:

PodioItem::create("#######", array(
  'fields' => array(
    'name' => array((int)$_POST['item_id'])
  )
));

Provided that name is the external_id of your app reference field!

  • Thanks Andreas, makes perfect sense this way around - do you know if I could get this to work in the other way? – Kobius Feb 27 '14 at 14:56
  • I'd like to use PodioItem::create to create a new item in another app, and then save the reference of that item back into my original item. So I guess I need to grab the response item_id from PodioItem::create and save that to my original "Main" app item. Any ideas? – Kobius Feb 27 '14 at 14:57
  • That's correct: $item = PodioItem::create(...); Then the item_id is in $item->item_id – Andreas Haugstrup Pedersen Feb 27 '14 at 15:09
  • Hi Andreas, I've got the item_id from the create response but in trying to update the app reference field I'm getting a "PHP Fatal error: Call to a member function set_value() on a non-object" error. Updated code here: http://pastebin.com/9m0LbG8N - am I correct in saying I need to initialise the field and then assign an ID to it? – Kobius Feb 28 '14 at 11:18
  • I think you are a bit confused about what the `field` method does. You are correct in assuming that you need to instantiate a new item field, but the `field` method cannot be used to assign values. It will only return a field if it already exists. Use `add_field` to add a field (it will replace any existing field with the same id) – Andreas Haugstrup Pedersen Feb 28 '14 at 17:42
  • Ah I see, got it now! I think using add_field combined with using the new item object instead of the ID has suddenly brought it all to life! Thanks Andreas - really appreciate your help, all the best! – Kobius Mar 06 '14 at 13:08