Podio : Troubles assigning reference for a Relatio

2019-08-12 12:16发布

I programmatically created an app with a relationship app field

$app = new PodioApp($attributes);

After it had been successfully created, I wanted to create a relationship app field

$field_id = PodioAppField::create( array (
                                        "type => "app",
                                        "external_id" => "test",
                                        "config" => array (
                                                        "label" => "Test field",
                                                        "settings" => array()
                                                    )
                                          ));

Indeed, the field is created in podio. Now, I want to assign the reference app for that relationship field and my code is as follow:

$settings = array( 
                "apps" => array (
                            array("app_id" => 10036463)
                          )
            );
PodioAppField::update($app->app_id, $field_id, array (
                                                        "label" => "Updated_test_field",
                                                        "settings" => $settings
                                                   ));

There is no error shown either on the screen or on log file. However when I check my app template on my workspace, the reference app to the relationship field is not set up.

So, if anybody could tell what's wrong with my settings, it would be nice :)

Thank you all

标签: php api podio
1条回答
疯言疯语
2楼-- · 2019-08-12 12:56

The config options are at: https://developers.podio.com/doc/applications

The settings name is not apps but referenced_apps and you can do this in one go. There's no reason to use 3 API calls when you can create your app with one:

$attributes = array(
  "fields" => array(
    array (
      "type => "app",
      "config" => array (
        "label" => "Test field",
        "settings" => array(
          "referenced_apps" => array("app_id" => 10036463)
        )
      )
    )
  )
);
$app = new PodioApp($attributes);

I've omitted all the other app attributes here. I've also removed external_id since one will be automatically generated for you.

查看更多
登录 后发表回答