0

嗨,有人可以帮我吗?我是使用 Javascript 编程的新手,我需要设置一个联系人到客户关系。

function SetRelationContact_Account(){
    $.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":["session":"' + SugarSessionId +
        '"]}'
    }, function(data) {
        if (data !== undefined) {
            var addAccountResult = jQuery.parseJSON(data);

        }

    });
}

我尝试创建新联系人,并且想与现有帐户建立关系。在 jmertic 的建议下,我尝试了以下方法,但仍然无效:

function SetRelationContact_Account(){
    $.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":["name":"account_id","value":"' + CurrentAccountId + '"]}'
   }, function(data) {
       if (data !== undefined) {
           var addAccountResult = jQuery.parseJSON(data);

       }

   });

}
4

1 回答 1

0

“related_ids”应该是您关联的记录的帐户 ID,并且应该采用 javascript 数组的形式。

于 2012-07-15T03:41:22.577 回答