Javascript 如何在联系人和帐户之间创建关系

Javascript 如何在联系人和帐户之间创建关系,javascript,contacts,sugarcrm,accounts,Javascript,Contacts,Sugarcrm,Accounts,嗨,有人能帮我吗?我是Javascript编程新手,需要设置联系人与帐户的关系 function SetRelationContact_Account(){ $.get(CurrentServerAddress + '/service/v2/rest.php', { method: "set_relationship", input_type: "JSON", response_type: "JSON", rest_data

嗨,有人能帮我吗?我是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);

       }

   });

}

“related_Id”应该是您正在关联的记录的帐户Id,并且应该是javascript数组的形式。

@MichelangeloMik:发布您尝试过的新代码的最佳位置是更新原始问题。在这种情况下,我是为你做的。问题标签区域下方的“编辑”链接允许您编辑问题。欢迎来到stackoverflow!