Results 1 to 2 of 2

Thread: Can't set relationship via REST API

  1. #1
    quantumized Guest

    Default Can't set relationship via REST API

    I'm using PHP Rest Service Version 4.1 and have spent three days trying to set a relationship between a record that I have just created via Rest and another existing record without success.

    I have tried every combination of code that I can think of. The result always say that one relationship was created but the records are never actually related.

    I have left the name_value_list array empty or off completely like the examples. I'm not sure what, if any, values may need to be in the attribute. Could this be the issue?

    PHP Code:
      $partner_bean '94597c8b-1a4e-6a20-81d9-51e6d7e764c8'// This is the ID of Partner Record that already exists
        
      //Set Related Partner Field
      
    $set_relationship_parameters = array(    
        
    'session' => $session_id,

        
    //The name of the module.
        
    'module_name' => 'stu_Students',

        
    //The ID of the specified module bean. ***
        
    'module_id' => $document_id// This is the ID of the newly created Partner Record

        //The relationship name of the linked field from which to relate records.    
        
    'link_field_name' => 'stu_students_accounts'// This is the related field name, the Stu_Students module is the primary module for this field/relation

        //The list of record ids to relate
        
    'related_ids' => array(
            
    $partner_bean,
        ),       

        
    'name_value_list' => array(),    // I have left this empty like the examples. Could this be the issue?

        
    'delete'=> 0,
        );
        
       
    $set_entry_result sugarapi_call("set_relationship"$set_relationship_parameters$url); 

  2. #2
    quantumized Guest

    Default Re: Can't set relationship via REST API

    UPDATE: It appears the relationships are actually being created but I still have a big problem and this is what was throwing me off.

    There is a "Partner Name" field on the Student module that needs to be populated with the name of the "Partner" that it is related to. The relation exists but I cannot seem to get this partner name field to populate. I thought for sure the following code would work, but the Partner Name field is always empty. When I set the relationship I've added this:
    PHP Code:
    'name_value_list' => array(
          array(
            
    'name' => 'partner_name2_c',
            
    'value' => 'Partner Name LLC',
          ) 
    'partner_name2_c' is the name of the field on the Student module that contains the name of the related Partner.
    'Partner Name LLC' is the name of the partner. This value is the EXACT value from the related Partner record.

    However, after I created the relationship with the added name_value_list values, the 'partner_name2_c' field is still empty.

    Any ideas??

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to Add Relationship Through Rest In SugarCRM
    By madhusudan2291 in forum Developer Help
    Replies: 1
    Last Post: 2013-05-21, 02:30 PM
  2. Insert Records In Relationship table Using REST
    By madhusudan2291 in forum Developer Help
    Replies: 4
    Last Post: 2013-03-23, 04:44 AM
  3. Insert a many to many relationship with REST API
    By Shot89 in forum Developer Help
    Replies: 6
    Last Post: 2012-04-16, 09:24 PM
  4. Replies: 0
    Last Post: 2012-02-15, 08:51 AM
  5. Replies: 2
    Last Post: 2010-05-18, 03:05 PM

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
  •