0

I trying to create a line of text in my SharePoint site that says something like, "For questions or problems regarding this site, please contact the site owner(s):" and then list the site owners.

I'm using the site users web part to accomplish this, but I would really like the list to be on one line, separated by commas instead of having each owner listed on their own row.

Like this:
"For questions or problems regarding this site, please contact the site owner(s): owner 1, owner 2, owner 3"

Not this:
"For questions or problems regarding this site, please contact the site owner(s):
owner 1
owner 2
owner 3"

Any ideas how to accomplish this?

0

You cannot do this OOTB way, you would have to write code to get users of Site owners group using JSOM or REST API and create required html based on data returned.

Use content editor webpart to add script to any page. Below is code snippet using REST API. Below snipped it adding users to dropdown, you need to modify it to and generate your html, with comma seperates site users.

<script src=”../SiteAssets/jquery-1.11.3.js”></script>
<script type=”text/javascript”>
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + “/_api/web/sitegroups/getByName(‘GroupName’)/users”,
type: “GET”,
headers: {“accept”: “application/json;odata=verbose”},
success: function (data){
if (data.d.results)
{
for (var i = 0; i < data.d.results.length; i++) {

//Loop through all users and binding in dropdown
if (data.d.results[i] != null && data.d.results[i] != undefined) {
if ($(“#ddlGroup option[value='” + data.d.results[i] + “‘]”).length == 0) {
$(‘#ddlGroup’).append($(“<option/>”, {
value: data.d.results[i].Email,
text: data.d.results[i].Title
}));
}
}
}
}
},
error: function (error) {
alert(JSON.stringify(error));
}
});
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.