AnsweredAssumed Answered

How to Relate Note record to Case record Using Soap/Rest

Question asked by Virat Kohli on Sep 29, 2015
Latest reply on Sep 30, 2015 by Virat Kohli
How to Relate Note record to Case record Using Soap/Rest.

i have creating Note using Rest and get one NOTE-ID in response.
and also having one case id and i want to make relation between this 2 records.


  $url = "http://ip/crm/service/v4_1/rest.php";
    $username = "admin";
    $password = "password";


    function call($method, $parameters, $url)
    {
        ob_start();
        $curl_request = curl_init();

        curl_setopt($curl_request, CURLOPT_URL, $url);
        curl_setopt($curl_request, CURLOPT_POST, 1);
        curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($curl_request, CURLOPT_HEADER, 1);
        curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);

        $jsonEncodedData = json_encode($parameters);

        $post = array(
             "method" => $method,
             "input_type" => "JSON",
             "response_type" => "JSON",
             "rest_data" => $jsonEncodedData
        );

        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
        $result = curl_exec($curl_request);
        curl_close($curl_request);

        $result = explode("\r\n\r\n", $result, 2);
        $response = json_decode($result[1]);
        ob_end_flush();

        return $response;
    }

    //login ----------------------------------------------------   
     $login_parameters = array(
         "user_auth" => array(
              "user_name" => $username,
              "password" => md5($password),
              "version" => "1"
         ),
         "application_name" => "RestTest",
         "name_value_list" => array(),
    );

    $login_result = call("login", $login_parameters, $url);

    //get session id
    $session_id = $login_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(
              //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" => "id", "value" => "98396f66-2dc4-e39a-3632-55de82f88afc"),
              array("name" => "name", "value" => "Test Note"),
             array("name" => "description", "value" => "ABCD@"),
            
         ),
    );

    $set_entry_result = call("set_entry", $set_entry_parameters, $url);


    echo $note_id = $set_entry_result->id;

    
     $set_relationship_parameters = array(
    //session id
    'session' => $session_id,

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

    //The ID of the specified module bean.
    'module_id' => $note_id,

    //The relationship name of the linked field from which to relate records.
    'link_field_name' => 'Cases',

    //The list of record ids to relate
    'related_ids' => array(
        '6822831b-8cc7-8330-fc82-539001de1383',
    ),

    //Sets the value for relationship based fields
    'name_value_list' => array(
        array(
            'name' => 'description',
            'value' => 'MSB'
        ),
    ),

    //Whether or not to delete the relationship. 0:create, 1:delete
    'delete'=> 0,
);
  
   $result1 = call('set_relationship',$set_relationship_parameters,$url); //nuSoap
   print_r($result1);
  


Its not creating relation.

Please Help !!!!!!!!!!!

Outcomes