php - Cannot update reference app field -


i have item referenced field app. call has assigned client.

i use library: http://podio.github.io/podio-php/

i followed article: http://podio.github.io/podio-php/fields/

i want update existing item changing item_id of field that's referencing app. item_id exists in other app.

here's tried (this happens when webhook triggered):

$item = podioitem::get($_post['item_id']); $item->fields['client']->values = array(     array('item_id' => $id_client) ); $item->save(array(     'hook'      => false,     'silent'    => true )); 

and

$item = podioitem::get($_post['item_id']); $item->fields['client']->values = array('item_id' => $id_client); $item->save(array(     'hook'      => false,     'silent'    => true )); 

where 'client' external id of field , $id_client integer number. here's error get:

[18-aug-2014 17:33:30 utc] php notice:  indirect modification of overloaded property podioitem::$field has no effect in /home1/magikweb/public_html/dev/magik-net/helpdesk/webhook/call.php on line 66 [18-aug-2014 17:33:30 utc] php warning:  creating default object empty value in /home1/magikweb/public_html/dev/magik-net/helpdesk/webhook/call.php on line 66 

if explain me why isn't working i'd grateful. provided documentation not clear on subject.

thank you!

solution

i got work way, credits andreas:

if(!isset($item->fields['client']->values[0]->item_id)){     $item->fields['client'] = new podioappitemfield();     $item->fields['client']->values = array(         array('item_id' => $id_client)     );     $item->save(array(         'hook'      => false,         'silent'    => true     )); } 

you're getting error because client field doesn't exist on item yet. you're trying set values doesn't exist.

you need (untested, should work):

$item = podioitem::get($_post['item_id']);  if (!isset($item->fields['client'])) {     $item->fields['client'] = new podioappitemfield(); }  $item->fields['client']->values = array(     array('item_id' => $id_client) ); $item->save(array(     'hook'      => false,     'silent'    => true )); 

when item podio won't fields in app, ones have values particular item. have check if particular field present before trying set values on it.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -