I have following code:
$.get(CurrentServerAddress + '/service/v2/rest.php', {
method: "set_relationship",
input_type: "JSON",
response_type: "JSON",
rest_data: '{"session":"' + SugarSessionId + '","module_name":"Contacts","module_id":"' + CurrentContactId + '","link_field_name":"accounts","related_ids":["'+ CurrentAccountId +'"]}'
}, function(data) {
if (data !== undefined) {
var addAccountResult = jQuery.parseJSON(data);
}
});
The relationship between Contacts and Companies working quite well. I would now like to assign a new company to the contact. I do not know how to do it.
As relationship between contacts and accounts is defined as a many-to-many and not a one-to-many if you want only one link between one contact and an account you should in first step delete the current relation and after adding your new relation
Something like that: