Uncaught TypeError: Cannot read property 'toLowerCase' of undefined when adding object to field in Sharepoint

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined when adding object to field in Sharepoint

我想在 SharePoint 页面上使用 JavaScript 自动填写 nintex 表单人员选择器字段。

问题是我一直收到错误消息:

当我点击第一个 link 时,它显示了这个

formMain.js中,错误是由这一行引起的:

ins.add(object);

我已经尝试了几个小时来解决这个问题,但我找不到解决方案。 正如您在控制台中看到的,insobject 都已定义。

这是我用来将用户添加到字段的 JavaScript:

var personProperties;

function onChangeProductManagement() {
    
    var curvalue = NWF$('#' + TeilnehmerStatus10).find("input:checked").val();
    var ins = new NF.PeoplePickerApi('#' + TeilnehmerName10);


    if (curvalue == "offen") {
        
        SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {
            // Make sure PeopleManager is available
            SP.SOD.executeFunc('userprofile', 'SP.UserProfiles.PeopleManager', function() {

                // Replace the placeholder value with the target user's credentials.
                var targetUser = "opmain\eoblae";

                // Get the current client context and PeopleManager instance.
                var clientContext = new SP.ClientContext.get_current();
                var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

                // Get user properties for the target user.
                // To get the PersonProperties object for the current user, use the
                // getMyProperties method.
                personProperties = peopleManager.getPropertiesFor(targetUser);

                // Load the PersonProperties object and send the request.
                clientContext.load(personProperties);
                clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
            });
        });

    } else {
        console.log("Test2");
        console.log("NWF value: " + NWF$('#' + TeilnehmerName10).val());
    }
}


// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {
    var accountName = personProperties.get_accountName();
    var displayName = personProperties.get_displayName();
    var email = personProperties.get_email();

    var object = { value: accountName, label: displayName, type: "user", email: email };
    console.log("object: ", object);

    var ins = new NF.PeoplePickerApi('#' + TeilnehmerName10);

    console.log("ins: ", ins);
    ins.add(object);
}

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
    console.log("Error: " + args.get_message());
}

感谢任何帮助!

var object 中添加 id 解决了问题。