我有以下代码:
$.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);
}
});
联系人与公司之间的关系运作良好。我现在想为联系人分配一个新公司。我不知道怎么做。
答案 0 :(得分:0)
这应该有用......
$.get(CurrentServerAddress + '/service/v2/rest.php', {
method: "set_relationship",
input_type: "JSON",
response_type: "JSON",
rest_data: '{"session":"' + SugarSessionId + '","module_name":"Accounts","module_id":"' + CurrentAccountId + '","link_field_name":"contacts","related_ids":["'+ CurrentContactId +'"]}'
}, function(data) {
if (data !== undefined) {
var addAccountResult = jQuery.parseJSON(data);
}
});
答案 1 :(得分:0)
由于联系人和帐户之间的关系定义为多对多而非一对多,如果您只想在一个联系人与帐户之间建立一个链接,则应在第一步中删除当前关系并在添加后添加你的新关系
类似的东西:
// Delete previous relation
$.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":["'+ OldAccountId +'"],"name_value_list":[],"deleted":"1"}'
}, function(data) {
if (data !== undefined) {
var addAccountResult = jQuery.parseJSON(data);
}
});
// Add previous relation
$.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":["'+ NeAccountId +'"],"name_value_list":[],"deleted":"1"}'
}, function(data) {
if (data !== undefined) {
var addAccountResult = jQuery.parseJSON(data);
}
});