Results 1 to 2 of 2

Thread: REST API - Create new Account and new Note tied to new Account

  1. #1
    Join Date
    May 2013
    Posts
    7

    Default REST API - Create new Account and new Note tied to new Account

    I am trying to use the API to create a new account, new note and then tie the two together with a relationship. I am new to the API and this process is not working. I can see that the new account and the new note is being created, but the connection / relationship is not working. What am I doing wrong.

    //create account ----------------------------------------

    $set_entry_parameters = array(
    //session id
    "session" => $session_id,

    //The name of the module from which to retrieve records.
    "module_name" => "Accounts",

    //Record attributes
    "name_value_list" => array(
    //to update a record, you will nee to pass in a record id as commented below
    //array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"),
    array("name" => "name", "value" => $dis_dist),
    array("name" => "clientlevel_c", "value" => $clientlevel_c),
    array("name" => "phone_office", "value" => $dis_phone),
    array("name" => "maincontact_c", "value" => $dis_first.' '.$dis_last),
    array("name" => "email1", "value" => $dis_email),
    array("name" => "products_c", "value" => $products_c),
    array("name" => "shipping_address_street", "value" => $dis_address),
    array("name" => "shipping_address_city", "value" => $dis_city),
    array("name" => "shipping_address_state", "value" => $dis_state_insert),
    array("name" => "shipping_address_postalcode", "value" => $dis_zip),

    ),
    );

    $set_entry_result = call("set_entry", $set_entry_parameters, $url);
    $sugar_id = $set_entry_result->id;



    //create note ----------------------------------------

    $set_entry_parameters = array(
    //session id
    "session" => $session_id,

    //The name of the module
    "module_name" => "Notes",

    //Record attributes
    "name_value_list" => array(
    array("name" => "name", "value" => "New Contact Created"),
    ),
    );

    $set_entry_result = call("set_entry", $set_entry_parameters, $url);
    $note_id = $set_entry_result->id;



    //set relationship ----------------------------------------

    $set_relationship_params = array(
    'session' => $session_id,
    'module_name' => 'Accounts', /* custom module, where the relationship was created, "primary module" */
    'module_id' => $sugar_id, /* id of site, get from set_entry call */
    'link_field_name' => 'Notes', /* the LINK field type name, from Step 5 */
    'related_ids' => $note_id /* id of Account you want to relate to */
    );


    $set_relationship_result = call("set_relationship", $set_relationship_params, $url);

  2. #2
    davidboris's Avatar
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,525

    Default Re: REST API - Create new Account and new Note tied to new Account

    Hello bstar,

    Set your link field name as 'notes' and try. It should work

    'link_field_name' => 'notes',
    Web : http://www.urdhva-tech.com
    Twitter : @urdhvatech
    Email : contact@urdhva-tech.com
    Blog : Urdhva-Tech
    Skype : urdhvatech

    Our Premium Projects for SugarCRM:
    Premium theme for SugarCRM CE (Community Edition 6.5+ with 4 combinations, Black + Orange/Red/Green/Blue, bootstrap3 based)
    Duplicate detector to avoid duplicate data entry.
    Customer Self Service Portal for All Flavours.
    tagMe A complete tag management for SugarCRM.
    Meeting Map Reminder Meeting reminder with Gmap in Email

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2013-05-16, 05:01 PM
  2. Replies: 1
    Last Post: 2012-06-11, 11:17 PM
  3. Create new account using REST API (set_entry) is not working
    By anoopmpaul in forum General Discussion
    Replies: 0
    Last Post: 2012-06-03, 04:26 PM
  4. Replies: 0
    Last Post: 2012-06-03, 04:17 PM
  5. Replies: 4
    Last Post: 2008-07-12, 02:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •