0

I'm writing a webpart that creates several SharePoint Groups. I'm trying to set the Group Owner so it's not defaulting to the user creating the group. According to documentation, this should be possible by passing the Group ID to Owner:

let newGroup = await myWeb.siteGroups.add({ Title: groupName, Description: "Example of creating a group", OnlyAllowMembersViewMembership: false, Owner: ownerGroupId});

When I test this, the request throws an error, which I'm able to see people complaining about since 2015. If I remove Owner from the parameters, everything works correctly.

Is setting the Owner supported? Am I missing something obvious?

1
  • Hi Andrew, do you have any documentation link where it is written about setting owner to the SharePoint group? I am also trying to do the same using pnpjs. Commented Jul 16, 2019 at 4:27

1 Answer 1

0

The owner receives a SP.Principal. In this case the owner it's a group. Unfortunately it doesn't put the user I chose but the user that created the group

import { sp, Web, PrincipalSource, PrincipalType, PrincipalInfo } from "@pnp/sp";

sp.utility.resolvePrincipal(managersGroupName,
  PrincipalType.SharePointGroup,
  PrincipalSource.UserInfoList,
  false,
  false,
  true).then(
    (OwnersPrincipal: PrincipalInfo) => {
       web.siteGroups.add({
       Title: newGroupName,
       Description: description,
       AllowRequestToJoinLeave: false,
       AutoAcceptRequestToJoinLeave: false,
       AllowMembersEditMembership: false,
       OnlyAllowMembersViewMembership: false,
       Owner: {
         LoginName: OwnersPrincipal.LoginName,
         Id: OwnersPrincipal.PrincipalId,
         PrincipalType: OwnersPrincipal.PrincipalType
       }
     });
   });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.