{"id":431,"date":"2015-12-15T22:24:14","date_gmt":"2015-12-16T03:24:14","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=431"},"modified":"2015-12-15T22:24:14","modified_gmt":"2015-12-16T03:24:14","slug":"query-for-sharepoint-groups-and-members-with-jquery-and-spservices","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=431","title":{"rendered":"Query for SharePoint Groups and Members with JQuery and SPServices"},"content":{"rendered":"<p>The following code returns all SharePoint permissions groups and the respective members.<br \/>\nThis uses <a href=\"https:\/\/jquery.com\/\" target=\"_blank\" rel=\"noopener\">JQuery 1.xx<\/a> and <a href=\"https:\/\/spservices.codeplex.com\/\" target=\"_blank\" rel=\"noopener\">SPServices<\/a>.<\/p>\n<pre>\n\n\/\/ Add JQuery and SPServices references. \/\/\n<script type=\"text\/javascript\"  src=\"\/jquery1.11.js\" ><\/script>\n<script type=\"text\/javascript\" src=\"\/jquery.SPServices.js\"><\/script>\n\n<script>\n\/\/ alert(\"Debug Check 1\");\n$(document).ready(function() {\n\/\/ Function returns all Permissions Groups\n$().SPServices({\n                        operation: \"GetGroupCollectionFromSite\",\n                        async: false,\n                        completefunc: function (xData, Status) {\n                                        $(xData.responseXML).find(\"Group\").each(function() {\n                                        \/\/ alert($(this).attr(\"Name\"));\n                                        getAllUsersFromGroup($(this).attr(\"Name\"));\n                                                                                           });\n                                                               }\n                });\n });\n                             \n                                                                       \n\/\/ Function returns all users in respective Groups                                           \nfunction getAllUsersFromGroup(groupName) {\n\/\/ alert(groupName);\n$().SPServices({\n                       operation: \"GetUserCollectionFromGroup\",\n                       groupName: groupName,\n                       async: false,\n                       completefunc: function (xDataUser, Status) {\n                                       $(xDataUser.responseXML).find(\"User\").each(function() {\n                                       $('#GroupUsers').append(\"<tr><td>\" + groupName + \"<\/td><td>\" + $(this).attr(\"Name\") + \"<\/td><\/tr>\");\n                                                                                              });\n                                                                   }\n                });\n}\n<\/script>\n\n<!-- Table for Output -->\n<table align=\"LEFT\" id=\"GroupUsers\">\n<tbody>\n<tr>\n<tr><td>Group<\/td><td>Member<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following code returns all SharePoint permissions groups and the respective members. This uses JQuery 1.xx and SPServices. \/\/ Add JQuery and SPServices references. \/\/ GroupMember<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[62,97,99,104],"class_list":["post-431","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-jquery","tag-sh","tag-sharepoint-2010","tag-spservices"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=431"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/431\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}