I have a script in PHP that runs a few things automatically on SugarCRM using RestAPI.
I’m using this PHP Class to manage the RestAPI:
http://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class/
Now I want to link a specific Contact to a ProspectList (Target List). I guess this must be made with a set_relationship call, but the PHPClass I am using does not have that.
I have tried writing the function myself like this:
public function set_relationship($module_ids, $module_names, $related_ids, $link_field_names){
$call_arguments = array(
'session' => $this->session,
'module_names' => $module_names,
'module_ids' => $module_ids,
'link_field_names' => $link_field_names,
'related_ids' => array($related_ids)
);
$result = $this->rest_request(
'set_relationship',
$call_arguments
);
return $result;
}
And then calling it like this:
$c->set_relationship(
$target_list['id'],
'ProspectLists',
$data['id'],
'Contacts'
);
But it does not work. Does anyone know how to make a REST/Soap call to connect a contact to a target list ?
Thank you
So I’ve finally figured it out, I’ve used the function from Kare’s answer:
But I had to make the call differently:
I hope this will help someone