Вопрос

How can I insert multiple users and groups in a user field of a Sharepoint Online list using Pnp-Js-Core?

greetings and thanks.

Это было полезно?

Решение

You can use it as below:

$pnp.sp.web.lists.getByTitle("Test").items.add({
    Title: "test",    
    MultiUserId: { 
        results: [ 9, 6 ]  // User/Groups ids as an array of numbers
    }
}).then(i => {
    console.log(i);
});

You need to pass an array of user ids or group ids.

Also, if your internal column name is MultiUser you need to set the column name as MultiUserId i.e append Id to your internal column name.

Also, ensure that your column settings are set as below:

enter image description here

Другие советы

Check the PnP Js documentation Work with Items here

User field will set the value based on the user/group id, very similiar with lookup field:

pnp.sp.web.lists.getByTitle("PeopleFields").items.add({
    Title: Util.getGUID(),
    User1Id: 9, // allows a single user
    User2Id: { 
        results: [ 16, 45 ] // allows multiple users
    }
}).then(i => {
    console.log(i);
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top