0

私は次のコードを持っています:

$.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);
    }
});

連絡先と会社の関係は非常にうまく機能しています。連絡先に新しい会社を割り当てたいと思います。どうやったらよいかわかりません。

4

2 に答える 2

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);
}

});

于 2012-08-09T12:48:11.863 に答える
0

連絡先とアカウントの関係は多対多として定義されているため、1つの連絡先とアカウントの間に1つのリンクのみが必要な場合は、最初に現在の関係を削除し、新しい関係を追加した後に行う必要があります。

そんな感じ:

// 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);
    }
});
于 2012-08-10T06:03:40.867 に答える