Problem on Create New Item with App Item Field (element no longer valid)

Answered

Comments

5 comments

  • Roberto Zanetti

    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;

    1
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Are you 100% sure person_name and role_type are the correct external ids for your fields?

    0
    Comment actions Permalink
  • Roberto Zanetti

    Hi Andreas, the routine do the following steps:
    1) Insert Role
    2) Insert person

    I 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?

    0
    Comment actions Permalink
  • Roberto Zanetti

    Andreas I have check now, the element that I have inserted before doesn't have the external_id.

    How I can insert the external_id in an element?

    0
    Comment actions Permalink
  • Roberto Zanetti

    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();

    ?>

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk