SharePoint 客户端人员选取器组 ID

SharePoint client side people picker group id

我已经使用 hmtl 和 jquery 创建了客户端人员选择器,如下所示 URL

https://www.c-sharpcorner.com/blogs/client-side-people-picker-in-sharepoint-2013

我可以输入用户名和组名,效果很好。但我想将用户和组保存到 SharePoint 列表中。它不适用于组名。我想确定它是用户还是组,如果组我想添加它与上面显示的用户相同url。

我正在寻找的是允许用户输入用户和组。一旦他们点击保存按钮,所有用户和组都应保存到 SharePoint 列表项

感谢任何帮助。

示例测试演示:

CustomPeoplePicker:
    <div id="peoplePickerDiv"></div>
    <input id="Button1" onclick="SaveItem()" type="button" value="button" />
    <script src="/_layouts/15/sp.runtime.js"></script>
    <script src="/_layouts/15/sp.js"></script>
    <script src="/_layouts/15/1033/strings.js"></script>
    <script src="/_layouts/15/clienttemplates.js"></script>
    <script src="/_layouts/15/clientforms.js"></script>
    <script src="/_layouts/15/clientpeoplepicker.js"></script>
    <script src="/_layouts/15/autofill.js"></script>
    <script src="_layouts/15/sp.core.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        })

        function sharePointReady() {
            context = new SP.ClientContext.get_current();
            web = context.get_web();
            var schema = {};
            schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
            schema['SearchPrincipalSource'] = 15;
            schema['ResolvePrincipalSource'] = 15;
            schema['AllowMultipleValues'] = true;
            schema['MaximumEntitySuggestions'] = 50;
            schema['Width'] = '280px';

            this.SPClientPeoplePicker_InitStandaloneControlWrapper('peoplePickerDiv', null, schema);
        }

        function SaveItem() {
            var ctx = new SP.ClientContext.get_current();
            var web = context.get_web();
            var list = web.get_lists().getByTitle("MyList");
            var listCreationInformation = new SP.ListItemCreationInformation();
            var listItem = list.addItem(listCreationInformation);
            var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan;
            // Get information about all users.
            var users = peoplePicker.GetAllUserInfo();
            // Get user keys.
            var keys = peoplePicker.GetAllUserKeys();
            var finalusers = new Array();
            for (var i = 0; i < users.length; i++) {
                var arryuser = users[i];
                finalusers.push(SP.FieldUserValue.fromUser(arryuser.Key));
            }
            listItem.set_item("Title", "Title");
            listItem.set_item("Requestor", finalusers);
            listItem.update();
            ctx.load(listItem);
            ctx.executeQueryAsync(
                Function.createDelegate(this, function () {
                    console.log(listItem);
                }),
                Function.createDelegate(this, function (sender, args) {
                    alert('Query failed. Error: ' + args.get_message());
                })
            );
        }
    </script>