0
votes

I'm creating a class with different methods to get values out of Podio fields. My idea was to create a program being able to get an X number of fields from an app. And it should be possible to delete fields or create new fields in the Podio app. I have created the application but somehow the program stops getting the values from the app, when I make some changes in Podio. I think the issue is in this method. This method should get all the external values of the fields, but the method stops getting some of the them when I change the app in Podio. I hope it makes sense. Otherwise please ask me for further details. The method is here:

public function getAllExternalIds(){

 // Get the first item of the app, only 1 item
  $items = PodioItem::filter($this->app_id,array('limit' => 1));

  // Create external_id array
  $exIds = array();
  // find all the external Ids of the item and put them in the array
   for($j=0;$j <count($items['items'][0]->fields) ;$j++){
   $exIds[$j] = $items['items'][0]->fields[$j]->external_id;       
  }
  //return the external Id array; 
  return $exIds;
}

The same issue is in this method:

public function getAllFieldNames(){
$items = PodioItem::filter($this->app_id,array('limit' => 1));

$fieldNames = [];
for($j=0;$j <count($items['items'][0]->fields) ;$j++){


 $fieldNames[$j] = $items['items'][0]->fields[$j]->label;


 }

 return $fieldNames;
 }
1

1 Answers

1
votes

Podio is extremely flexible platform and you can change app template (list of fields) and keep existing items unchanged, and I'm afraid that this is exactly what you are facing.

Let's review it on example:

  1. There is an app, let's call it 'Projects', and app template has only 2 fields: 'Title' and 'Deadline'.
  2. Then you create 1 item with 'Title' and 'Deadline' fields.
  3. Then you can change app template and add 'Details' field and remove 'Deadline' field.
  4. And create 1 more item.
  5. And then you can change app template again and remove both 'Title' and 'Details' fields and add 'Responsible' field.
  6. Now items_1 has 'Title' and 'Deadline' fields and your methods will get those 2 fields, and item_2 has 'Title' and 'Details' fields, and app template actually has only 'Responsible' field and doesn't match none of those.

So, you should probably use https://developers.podio.com/doc/applications/get-app-22349 method to read current app configuration and settings.