无法使用自定义对象重置 Archer 记录权限字段

问题描述 投票:0回答:1

设置记录权限字段时,下面的代码工作得非常好。

但是,当从交叉引用重置选择时,单击保存按钮后记录权限字段会被清除,但是当将记录退出到查看模式时,记录权限字段会保留以前的值,就好像该值没有被清除/重置一样。这是最近开始发生的奇怪行为。

任何使用不同代码来重置/删除记录权限字段的人。 谢谢。

SaaS,版本:2024.09,内部版本:6.15.00302.10262

function AssignUser() {
    UserArr = [];
 
    var selectedUserId = $('input[name*="SelectedValues' + fldIds.SelectUser + '"]').val();
    if (selectedUserId != '[]') {
        var selUserId = selectedUserId.substring(1, selectedUserId.length - 1);
        userId = GetAssociatedContactUser(selUserId);
        UserArr.push({
            id: userId,
            name: ""
        });
    }
    GetUserName(UserArr);
    SetRecordPermission(UserArr, FieldId, 'user');
}
function GetUserName(userArr) {
    var i;
    for (i = 0; i < userArr.length; i++) {
        var url = baseURL + "/api/core/system/user/" + userArr[i].id;
        var headers = {
            'x-csrf-token': csrfToken
        };
 
        $.ajax({
            headers: headers,
            url: url,
            data: '',
            type: 'GET',
            contentType: 'application/json',
            processData: false,
            async: false,
            dataType: 'json',
            success: function (data, textStatus, jqXHR) {
                //alert(JSON.stringify(data.RequestedObject, undefined, 2));                        
                userArr[i].name = data.RequestedObject.DisplayName;
            },
            error: function (data, textStatus, jqXHR) {
                alert(JSON.stringify(data, undefined, 2));
            }
        });
    }
}
 
function SetRecordPermission(buStaff, flId, itemType) {
 
    var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(flId),
        UsrArray = [];
    var RPFieldRootId = RPFieldRoot.clientId;
    var displayNames = "";
    var ids = "";
    var i;
    for (i = 0; i < buStaff.length; i++) {
 
        UsrArray.push({
            name: buStaff[i].name,
            value: buStaff[i].id + ":" + (itemType == "group" ? 2 : 1)
        });
        displayNames += buStaff[i].name + " ";
        ids += buStaff[i].id + ",";
 
    }
 
    var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
    ids = ids.substring(0, ids.lastIndexOf(','));
 
    //alert(serialized);    
    $('input[id*="' + RPFieldRootId + '_"]').val(serialized);
    $('div[id*="' + RPFieldRootId + '_"] div:first-child').text(displayNames);
 
    if (itemType == "group") {
        $('#SelectedGroups' + flId).val(ids);
    } else {
        $('#SelectedUsers' + flId).val(ids);
    }
}
 
function GetAssociatedContactUser(ctId) {
    var id = 0;
    var userid;
    var url = baseURL + "/api/core/content/" + ctId;
    var headers = {
        'x-csrf-token': csrfToken
    };
 
    $.ajax({
        headers: headers,
        url: url,
        data: '',
        type: 'GET',
        contentType: 'application/json',
        processData: false,
        async: false,
        dataType: 'json',
        success: function (data, textStatus, jqXHR) {
            userid = data.RequestedObject.FieldContents[fldIds.RSAArcherUserAccountCT].Value;
        },
        error: function (data, textStatus, jqXHR) {
            alert(JSON.stringify(data, undefined, 2));
        }
    });
 
    if (userid !== null && userid !== 'undefined')
        return userid.UserList[0].Id;
    else
        return id;
}
});
javascript custom-object archer rsa-archer-grc
1个回答
0
投票

替换这两行,

$('input[id*="' + RPFieldRootId + '_"]').val(serialized);
$('div[id*="' + RPFieldRootId + '_"] div:first-child').text(displayNames);

随着(如果我错过了变量,可能需要相应地更新它们)

$('div[id*="'+ RPFieldRootId.clientId +'_"] div:first-child').html(displayNames);
$('input[id*="'+ RPFieldRootId.clientId +'_"]').val(serialized);
$('input[id*="SelectedUsers'+ fld +'"]').val(displayNames);

var usersGroups = $CM.getFieldControl($CM._fields[fld])
var tree = $find(usersGroups.get_treeViewId());
tree.set_popupValue(UsrArray);

看看是否有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.