Issues with update() using app reference field

Answered

Comments

6 comments

  • Andreas Haugstrup Pedersen

    Going from memory here, but once you go down the array path you need a lot of them. Attempt this:

    "values" => array(array("value" => 19380159), array("value" => 18088765));

    0
    Comment actions Permalink
  • Nick Worth

    I'll try that real quick too, I just got a result doing this:

    $new_student = $this->api->item->updateFieldValue(18087177,17703085,

          array(

                19380159,

                18088765

          )

    ** );**

    My question though is since I need to put the new ID and the current IDs, is there an easy way to get the current IDs already attached to this item_id?

    Thanks for the quick response as well I really appreciate it, trying to wrap this thing up tonight

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    You'd have to either get the whole item and find the field and value or use getFieldValues. If you are doing a lot of calls use getFieldValues since it has a higher API rate limit

    0
    Comment actions Permalink
  • Nick Worth

    I think I got it. I did this as a test and it seems to work so now I'm going to plug my variables back in and should be good to go :)

    $test = $this->api->item->getFieldValue(18087177,DONOR_STUDENTS);

    ** $instance;**

    ** foreach($test as $i => $t){**

          $instance[$i] = $t['value']['item_id'];

    ** }**

    ** try {**

          $student_id = floatval($new_student['item_id']);

          $new_student = $this->api->item->updateFieldValue(18087177,$student_id,$instance);

    ** }**

     

    0
    Comment actions Permalink
  • Patrick Steil

    Hey guys... related to Nick's question... I need to find a PHP code sample for how to create an item which has an app reference... 

    I am successfully creating my item which has fields "title" and "text" like this:

     

    $fields = array(

    array('external_id'=>'title', 'values'=>array('value'=>$this->title)),

    array('external_id'=>'text', 'values'=>array('value'=>$this->template_content)),

    );

    $template_item = $this->api->item->create($_SERVER['HELPDESK_TEMPLATES_APP_ID'] , array('fields' => $fields));

     

    In this same app, if I have a field called "Release" and need to link this up to my "Releases" app item - assuming my Releases app item ID is stored in a variable called $ReleaseItemID, and and field ID of the Release variable is in var called $ReleaseFieldID...  what is the syntax to link up the app reference?

    Thanks for any help!

    Patrick Steil 

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    All code untested because that's how I roll this morning. :)

    With the new PHP client:

    $field = new PodioAppItemField(array('field_id' => $ReleaseFieldID);

    $field->set_value($releaseItemID);

    $item = new PodioItem(array('app' => new PodioApp($app_id));

    $item->fields = array($field);

    $item->save();

    With the ancient PHP client you'll need to build your array or arrays yourself:

     array('field_id' => $ReleaseFieldID, 'values' => array(array('value' => $ReleaseItemID));

    // You may be able to get away with, but I'm unsure

    array($ReleaseFieldID => $ReleaseItemID); 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk