Thursday, November 30, 2023

Get SharePoint all users from in the Group Using the Group Name or Group Id

 In this blog I am explaining how to get all uses form SharePoint group using Name and Id with REST

Get All Users from Groups Name

"_api/web/sitegroups/getbyname('" + groupname + "')/users/"

Get All Users from Groups ID

"/_api/web/sitegroups/GetById(" + groupID +")/Users"

Suppose If you getting Groupe Name from textbox and in will contain special character such as "&" or you can use the Group-id method

var groupName = encodeURIComponent(groupname);
_spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups?
                    $filter=LoginName eq '" + groupName + "'"

Additionally If you need to group details related to the the login user use following method

"/_api/web/sitegroups?$filter=substringof('" + groupname + "',LoginName)"



0 comments:

Post a Comment