sugarcrm REST 更新 关系 beteen 联系人和帐户 javascript
sugarcrm REST update Relationship beteen Contacts and Accounts javascript
我有以下代码:
$.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);
}
});
联系人和公司之间的关系运作良好。我现在想为联系人分配一家新公司。我不知道该怎么做。
由于联系人和客户之间的关系被定义为多对多,而不是一对多,如果您只希望一个联系人和客户之间有一个链接,您应该在第一步中删除当前关系,然后在添加新关系后
删除像这样:
// 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);
}
});
这应该有效...
$.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);
}
});
相关文章:
- 通过javascript跨浏览器访问outlook联系人文件夹
- 使用JavaScript切换联系人表单字段
- 如何使用Javascript和HTML5数据库替换表中的现有联系人
- Javascript按钮,它提交联系人表单7表单,然后重定向到URL
- 如何在联系人表单7 Wordpress中添加自定义javascript函数
- 如何使javascript联系人表单正确提交
- 获取所有用户's的联系人列表(包括电话号码)来自javascript中的谷歌登录
- 使用 javascript 获取 google 联系人
- Javascript联系人未显示
- 如何通过JavaScript管理Google帐户的联系人
- 联系人表单变量不会从部分标签传递到 javascript 中
- 使用 Javascript 中的 Google People API 获取联系人电子邮件地址
- 使用 Javascript (CodeCademy) 制作更好的联系人列表显示
- 如何使用JavaScript验证联系人表单
- 第二个javascript不适用于我的联系人表单
- 使用javascript验证联系人表单
- 在Javascript中隐藏联系人表单
- Javascript联系人列表
- Javascript联系人表单没有从下拉列表中返回所选值
- 我的javascript联系人表单没有'不起作用