Update Category in Item
I've tried multiple methods of changing a category from option 1 to option 2 and none of them are working properly.
Examples:
$item = PodioItem::get_basic($ItemID);
$field_id = 'print-to-pdf';
$item->fields[$field_id]->values = 2;
(this is the simplest version, following the API documentation. The category doesn't change. $ItemID is retrieved from the original POST and is correct)
PodioItem::update($ItemID, array('fields' => array("print-to-pdf" => array('id' => 2))));
(This is typically used for updating multiple fields but can be used for one as well, doesn't work.)
PodioItemField::update( $ItemID, $FieldID, array(), array(2));
(This one I've used to successfully update raw data fields, but it isn't working for categories.)
Could I get some help here?
Thank you
-
The problem is this. I have a Podio item with a category field. The option ID's of the categories are 1, 2, and 3. When option 1 is selected within the Podio platform, a webhook is triggered and a php script on my server runs. However, after the script runs I need to change the selected option from "1" to "2". (these are the optionIDs). The problem is, whatever script I run, following the API documentation, the category does not update from option 1 to option 2.
Simply put, using PHP I'm trying to select the second option of my category within an item.
Any help?
-
It should work then. Could you try enable debugging and share the output please? http://podio.github.io/podio-php/debug/
-
So here's the output from the log file.
2015-09-19 00:47:40 400 PUT /item/322660606
2015-09-19 00:47:40 Request body: {"fields":{"print-to-pdf":{"id":2}}}
2015-09-19 00:47:40 Reponse: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/322660606","query_string":"","method":"PUT"},"error_description":"Invalid value null (null): Not a valid option","error":"invalid_value"}
This was created using the PHP code:
PodioItem::update($ItemID, array('fields' => array("print-to-pdf" => array('id' => 2))));
So from what I understand it's telling me that my 'id' entry is wrong? But here is the item information:
{
"status": "active",
"external_id": "print-to-pdf",
"config": {
"default_value": null,
"description": null,
"settings": {
"multiple": false,
"options": [
{
"status": "active",
"text": "Create engagement",
"id": 1,
"color": "DCEBD8"
},
{
"status": "active",
"text": "Engagement letter created",
"id": 2,
"color": "DCEBD8"
},
{
"status": "active",
"text": "Engagement letter sent",
"id": 3,
"color": "DCEBD8"
}
],
"display": "inline"
},
So I don't understand why it is telling me the value is wrong.
Any idea what is going on here?? -
What does the output look like if you use the approach described here instead? http://podio.github.io/podio-php/fields/#setting-values-1
-
Using that method still doesn't work. My code is as follows:
$item = PodioItem::get_basic($ItemID); $field_id = 'print-to-pdf'; // Set value to a single option $item->fields[$field_id]->values = 3; // option_id=4
$ItemID comes from the webhook that is triggered.
The log file is too large to post here, but I've uploaded it at this link: http://www.filedropper.com/podio
The request should be made at the end, but I'm not seeing it.
-
I think there's a
save
missing as shown here: http://podio.github.io/podio-php/items/#change-field-value -
No, it's still not showing the update. Not that I'm seeing anyway. The final request is a GET request.
Here's the new log.
Please sign in to leave a comment.
Comments
12 comments