Sharepoint group description – add link or other HTML

One of these days I needed to provide rich sharepoint group descriptions, with html, and even a link.

Setting the description directly on the SPGroup object had the HTML being escaped and displayed on the group list page, which was not the wanted result.

So, how to get the rich description, like on OOTB sharepoint groups?

Let’s assume that our group is called “TestGroup“, and that the spWeb contains ou SPWeb object.

We’ll just add the intended description to the site information list, to an item with our group id. In this case we have a link to the SPWeb, being added at the end of the description:

    var groupId = spWeb.SiteGroups["TestGroup"].ID;
    var description = string.Format("This description has a link:  <a href=\"{0}\">{1}</a>", spWeb.Url, spWeb.Title);
    SPListItem item = spWeb.SiteUserInfoList.GetItemById(groupId);
    item["Notes"] = description;

That’s it. Hope it’s useful.


Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>