Forum Discussion
Brent Ellis
Feb 08, 2017Silver Contributor
"My Groups" list for SharePoint Homepage Web Part
So, we are about to do some major rollout of Groups to our company. While there are a million "entry points" for Groups, we simply wanted a list of Groups that a member belongs to on our Intranet Ho...
Brent Ellis
Silver Contributor
Hmm, I opted to use api and script editor web part to create our web part
Perhaps cfiessinger can flag someone down that knows how search indexing + Groups is working. We havent started using Groups for permissions elsewhere yet, but are definitely planning to and if this is the case, that is a big issue.
<SCRIPT LANGUAGE='JavaScript' type='text/javascript'> $(document).ready(function () { $.ajax({ url : "https://mytenant.sharepoint.com/sites/groups/_api/web/lists/getByTitle('my')/Items?$OrderBy=Title", contentType : "application/json;odata=verbose", headers : { "accept" : "application/json;odata=verbose" }, success : function onSuccess(data, request){ if(data.d.results.length == 0){ $("#listOfGroups").html("No Groups"); } else { for(i=0;i<data.d.results.length;i++){ //console.log(data.d.results[i]); html = "<B>"+data.d.results[i].Title+"</B><BR>" if(data.d.results[i].Conversation){ html += "<a style='font-size:16px;' title='Group Conversations' href='"+data.d.results[i].Conversation.Url+"' target='_blank'><i class='fa fa-comments-o' aria-hidden='true'></i></a> | "; } if(data.d.results[i].Calendar){ html += "<a style='font-size:16px;' title='Group Calendar' href='"+data.d.results[i].Calendar.Url+"' target='_blank'><i class='fa fa-calendar' aria-hidden='true'></i></a> | "; } if(data.d.results[i].Files){ html += "<a style='font-size:16px;' title='Group Files' href='"+data.d.results[i].Files.Url+"' target='_blank'><i class='fa fa-folder-open-o' aria-hidden='true'></i></a> | "; } if(data.d.results[i].Notebook){ html += "<a style='font-size:16px;' title='Group Notebook' href='"+data.d.results[i].Notebook.Url+"' target='_blank'><i class='fa fa-book' aria-hidden='true'></i></a> | "; } if(data.d.results[i].Site){ html += "<a style='font-size:16px;' title='Group SharePoint Site' href='"+data.d.results[i].Site.Url+"' target='_blank'><i class='fa fa-sitemap' aria-hidden='true'></i></a>"; } } $("#listOfGroups").html(str); } }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR); } }); }); </SCRIPT> <div id="listOfGroups"></div>
Note, we've got font-awesome embedded for the icons.
Alexander Zoutenbier
Nov 22, 2017Copper Contributor
Great code! Used it with the combination of Promoted Links.
Thanks!