Forum Discussion
"My Groups" list for SharePoint Homepage Web Part
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.
Hi Brent Ellis,
I am trying to recreate the end-user visual web part based on the script you provided. However, I am not getting anything populated (the API is set, I just can't get the records to display? The Str is not defined? Any insight on this? Any help is appreciated.
- Brent EllisDec 03, 2018Silver ContributorPerhaps my mistake in a poor copy paste, it looks like
$("#listOfGroups").html(str);
should be
$("#listOfGroups").html(html);
in the above example- hgromekDec 04, 2018Copper Contributor
My again! Any insight on how to pull in Team conversations or planner URLs?
- hgromekDec 03, 2018Copper Contributor
Brent Ellis thanks! that fixed it! One more question (please forgive me I am pretty novice at jquery) it doesn't seem to be storing all the groups it's looping through. I am only seeing the last group displayed. Any insight on how to fix this?
- hgromekDec 04, 2018Copper Contributor
Solved, needed to establish the HTML variable and change the Title Html to html+. Thanks for this work!