AnsweredAssumed Answered

Having trouble creating a relationship between a Contact and Lead using PHP and SOAP

Question asked by alain calvillo on Feb 7, 2017

Im trying to create a lead, and then an opportunity, and then link the Lead to the opportunity.. I am using soap and PHP.. but I keep getting the error "Module Does Not Exist"

 

Here is my code...

 

 

//submit lead to CRM
$set_entry_params = array(
'session' => $session_id,
'module_name' => 'Leads',
'name_value_list'=>array(
array('name'=>'first_name','value'=>"alain"),
array('name'=>'last_name','value'=>"cal"),
array('name'=>'email1','value'=>"email@site.com"),
array('name'=>'team_id', 'value'=> '1'),
array('name'=>'assigned_user_id', 'value'=>$user_guid)
));

try {
$result = $client->__soapCall('set_entry',$set_entry_params);
$lead_id = $result->id;
var_dump($result);
} catch (Exception $e) {
var_dump($e);
}

 

// create a Opportunity
$call_arguments = array(
'session' => $session_id,
'module_name' => "Opportunities",
'name_value_list' => array(
array('name'=>'name','value'=> '555 Main Street, Houston Texas 77081'),
array('name'=>'sales_stage' ,'value'=>'New Inquiry'),
array('name'=>'amount' ,'value'=> '100'))
);

try {
$result = $client->__soapCall('set_entry', $call_arguments);
$opp_id = $result->id;
var_dump($result);

} catch (Exception $e) {

}



// problems below
$call_arguments = array(
'session' => $session_id,
'module_name' => 'Opportunities',
'module_id' => $opp_id,
'link_field_name' => 'leads',
'related_ids' => array($lead_id),
// 'name_value_list' => array(),
'delete' => 0,
);


try {
$result = $client->__soapCall('set_relationship', $call_arguments);
var_dump($result);
} catch (Exception $e) {
var_dump($e);
}

Outcomes