Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This code snippet used to create a new group with different parameters in SharePoint Site Collection using PnP JavaScript Library
//Author: Shantha Kumar T
//Supports: SharePoint Online, SharePoint 2013+
//PnP JavaScript file available from
//More details:
<script type="text/javascript" src="/siteassets/scripts/fetch.js"></script>
<script type="text/javascript" src="/siteassets/scripts/promise.min.js"></script>
<script type="text/javascript" src="/siteassets/scripts/pnp.min.js"></script>
<div id="sample"></div>
<script type="text/javascript">
//The below PnP property used to create a new SharePoint Group
Title: "Group Name 2",
Description: "My description for the new group",
AllowRequestToJoinLeave: true,
AutoAcceptRequestToJoinLeave: true,
RequestToJoinLeaveEmailSetting: "",
AllowMembersEditMembership: true,
}).then(function(result) {
samgrp =;
var grpInfo = "";
var grp =;
grpInfo += "SharePoint Group '<strong>" + grp.Title + "</strong>' created successfully!<br/>";
grpInfo += "Below are some of the newly created group properties,<br/>";
grpInfo += "Description :" + grp.Description; + "<br/>";
grpInfo += "AllowMembersEditMembership: " + grp.AllowMembersEditMembership + "<br/>";
grpInfo += "OnlyAllowMembersViewMembership: " + grp.OnlyAllowMembersViewMembership + "<br/>";
grpInfo += "AllowRequestToJoinLeave: " + grp.AllowRequestToJoinLeave + "<br/>";
grpInfo += "AutoAcceptRequestToJoinLeave: " + grp.AutoAcceptRequestToJoinLeave + "<br/>";
grpInfo += "RequestToJoinLeaveEmailSetting: " + grp.RequestToJoinLeaveEmailSetting + "<br/>";
document.getElementById("sample").innerHTML = grpInfo

This comment has been minimized.

Copy link

@vochitan90 vochitan90 commented Aug 5, 2020

It always by default who create the group and not possible to update the group owner. How to update group owner?
I know we have "owner" parameter but I don't know how to use it. Please advice, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment