Problem on Create New Item with App Item Field (element no longer valid)
Answeredhi Guys, I have a problem on insert a new item in an app, this app has a field the is referenced with another app.
The message tell something like "element is no longer valid" in english.
$item = new PodioItem(array(
'app' => new PodioApp($app_id),
'fields' => array()
));
// We can add some fields to the item:
$item->fields = array(
new PodioTextItemField('person_name'),
new PodioAppItemField('role_type')
);
$item->field('person_name')->set_value($person_name);
$item->field('role_type')->set_value($role_type);
$item->save();
this is the error message:
Fatal error: Uncaught PodioBadRequestError: "La referenza a roberto1 11 1 in Tipi Ruolo non è più valida" Request URL: http://api.podio.com/item/app/7291547/ Stack Trace: #0
can someone please help?
-
Hi Andreas, the routine do the following steps:
1) Insert Role
2) Insert personI save the role, and after that I call
PodioItem::filter($app_id_role, array('filters' => array('id_role' => array('from' => $role, 'to' => $role) )
));(Where $role is the ID that user entered, not the system ID)
After that I get the system ID with
if ($item_collection['filtered'] > 0)
{
$item = $item_collection['items'][0];
$role = $item->id;
}The external ID are the ID of the table that I want to refer, right?
-
Ok, so I try to understand, now I use the external id of the other app, API return no error but in the new record I don't see the relation.
Here is the code:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
ini_set('log_errors',1);
ini_set('log_errors_max_len',0);
ini_set('ignore_repeated_errors',0);
ini_set('ignore_repeated_source',0);
ini_set('report_memleaks',1);
ini_set('track_errors',1);
ini_set('error_log','error_podio.log');require_once 'PodioAPI.php';
require_once 'PodioConfig.php';Podio::setup($CLIENT_ID, $CLIENT_SECRET_KEY);
Podio::$debug = true;
date_default_timezone_set('Europe/Berlin');
$oldLocale = setlocale(LC_TIME, 'it_IT', 'it_IT.utf8');
setlocale(LC_TIME, $oldLocale);$error_code = 0;
$app_id_persona = [APP ID HERE];
$app_token_persona = [APP TOKEN HERE];$username = [USERNAME HERE];
$password = [PASSWORD HERE];Podio::authenticate('password', array('username' => $username, 'password' => $password));
$persona_id = 123123123;
$persona_nome = 'Sig. Name Surname';
$persona_ruolo_id = 'share_119557858';
$persona_ente_id = 129954502;
$persona_email = 'mail@email.com';
$persona_telefono = '09090909';$item = new PodioItem(array(
'app' => new PodioApp($app_id_persona),
'fields' => array()
));$item->fields = array(
new PodioTextItemField('titolo-nome-e-cognome'),
new PodioTextItemField('email-professionale'),
new PodioNumberItemField('numero'),
new PodioTextItemField('recapito-telefonico'),
new PodioTextItemField('contact-notes'),
new PodioAppItemField('tipo-ruolo'),
new PodioAppItemField('ente')
);$item->field('titolo-nome-e-cognome')->set_value($persona_nome);
$item->field('tipo-ruolo')->set_value($persona_ruolo_id);
$item->field('email-professionale')->set_value($persona_email);
$item->field('numero')->set_value($persona_id);
$item->field('recapito-telefonico')->set_value($persona_telefono);$item->save();
?>
-
Hi Andreas, I have solve the problem, the app field was refered to another app (with the same name and structure) in another workspace. So the code works fine and is correct, but we must use the item_id not external_id to connect the field with app.
the code should change this line (that use external_id)
$persona_ruolo_id = 'share_119557858';
With this one (that use item_id):
$persona_ruolo_id = 1231231434;
Please sign in to leave a comment.
Comments
5 comments