2

hello I have 2 entties in sugar crm

  1. Application
  2. Candidate

Application has a relation with candidate. Now i want enter data using soap api to application with candidate name which is relational field

Please help

Ghan Shyam
  • 626
  • 1
  • 6
  • 18

1 Answers1

2

My suggestion for SugarCRM 5.5. However, based on the releationship type you defined, it might need some changes.

<?php
require_once 'nusoap.php';
$sugarClient = new soapclient($myUrl, true);
$response = $sugarClient->login(array('user_name' => $myUser, 'password' => md5($myPass), 'version' => '1'), 'myApp');
$sessionId = $response['id'];

$response = $sugarClient->get_entry_list($sessionId, 'Applications', 'name = '. $myValue, $myOrderBy, 0, array('id'));
$applicationId = $response['entry_list'][0]['id'];

$myCandidate = array(array('key' => $myVal1, 'key2' => $myVal2)); 
$response = $sugarClient->set_entry($sessionId, $myCandidate);
$candidateId = $response['id'];

$myRelation = array('module1' => 'Candidates', 'module1_id' => $candidateId, 'module2' => 'Applications', 'module2_id' => $applicationId);    
$sugarClient->set_relationship($sid, $myRelation);

$sugarClient->logout($sessionId);
?>

For more info see: http://www.sugarcrm.com/crm/support/documentation/SugarCommunityEdition or search google for some examples.