SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the Flat.aspx page of a discussion forum, I have to highlight the reply if the poster belongs to a certain group. How do I achieve that?

I tried modifying the Profile.xsl file that the list view uses, but none of the changes are getting reflected. Am I looking at the wrong xsl file? Or is there some other way to do it?

share|improve this question

This could be accomplished on client side. Below is provided full solution description.

Script for highlighting discussion list replies:

ExecuteOrDelayUntilScriptLoaded(highlightDiscussion, "sp.js");

function highlightDiscussion()
   var discussionGroupId = 3;
   var clientContext = new SP.ClientContext.get_current;
   var groups = clientContext.get_web().get_siteGroups();
   var group = groups.getById(discussionGroupId);   //
   this.groupUsers = group.get_users();
   clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));


function resolveUserForReply(replyItem)
     var userEntry = {};
     var replyRow = replyItem.closest('tr');
     var userUrl = replyRow.find('a').attr('href');
     userEntry.ID = userUrl.match(/ID=([^&]+)/)[1];
     return userEntry;

function highlightReply(replyItem)
    replyItem.css({'background-color': '#00ffcc'});

function highlightReplyForUser(userId)
    $('div[class^="ExternalClass"]').each(function(index) {
        var user = resolveUserForReply($(this));
        if(userId == user.ID)

function onQuerySucceeded() {
    var ie = groupUsers.getEnumerator();
    while (ie.moveNext()) {
       var user = ie.get_current();

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

How to make it work:

  1. Save this script as a file DiscussionsHighlight.js and place it to LAYOUTS folder
  2. Embed specified file and jquery files into discussion list, for example add it to Flat.aspx like shown below:

enter image description here


On picture below is displayed discussion list with highlighted replies for users who belongs to specific group (see parameter discussionGroupId in script )

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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