Freigeben über


Custom column of type "People/Group" named say: "last replied by" for team discussions which reflects the person/group who last replied to the thread in the topic (specific to that topic) in the discussion board in MOSS

Requirement

  1. End User requires an OOB column of type "People/Group" named say: "last replied to" in Discussion Board. This column should show the Person/Group who last replied to the thread specific to the topic in the Discussion Board.
  2. Currently, there is an OOB Column "LastUpdated" which shows the timestamp as when was last replied (Date/Time) on the topic, but there is no such OOB column which shows as who last replied to the topic in the discussion board
  3. Besides, there is an OOB Column "LastModifiedBy", but that reflects the Person/Group who modified the Topic details and not the one who replied to the topic in the discussion board
                    In short, WE require a Custom column of type "People/Group" named say: "last replied by"  (People/Group Type) for team discussions which reflects the person/group who last replied to the thread in the topic (specific to that topic) in the discussion board in MOSS 2007

Steps To Understand The Requirement

  1. Create an OOB Discussion Board
  2. Add the following fields to the default View: ModifiedBy, LastUpdated, Modified
  3. Add the topic to the discussion board
  4. Now, Reply to the topic
  5. Check the value for the column "LastUpdated"; the TimeStamp chnges every time we reply to the topic.
  6. Now, modify the topic properties by right click n say edit properties.
  7. Check the value of the column "Modified" & "ModifiedBy"; it reflects the TimeStamp and the Person/Group who modified the topic
  8. But, there is no OOB column which reflects the Person/Group who last replied on the topic. Just there is a timestamp "LastUpdated".

Resolution / Work Around

  1. An event handler (
  2. Note:
  3. onItemUpdated) attached to the Discussion board, which tracks as whenever a user replies to the topic assigns the name of the user to the custom column (which is non-editable by the users) of the Topic in the discussion board.
  4. Created 1 custom column of Type:People/Group named “LastRepliedBy” in the Discussion board “Team Discussion”.
  5. Attach the 2 event handlers defined in FieldAddedEvntHand folder using application contained in ConsoleApplication1 folder
  6. Now, add the discussion topic and reply to the thread.
  7. Check the output in non-editable column “LastRepliedBy”
  • Note:
  • Here, the custom column is made non-editable so that it is not seen by users while adding topics in the discussion board.
  • Currently, the given code is specific to the named discussion board. But, we can write feature related xml to deploy the code as as feature so that on activation it can work for any OOB Discussion Board in the site. Besides, We can also attach the handler code with SiteStapler Feature by writing an xml file for it. This will result in activation of the feature at the time site is created.

Attachment:

  1. The attachment contains Sample_Files.zip which in turn contains 2 folders for reference:
  2. FieldAddedEvntHand folder : contains the Class Library Application
  3. ConsoleApplication1 folder : contains the Console Application

Steps for Deploying The Code

  1. Open the class library project: FieldAddedEvntHand in Visual Studio 2005 or later version

    1. Make necessary changes in the code:
      1. In File: Class2.cs ; Method: FieldAdded ; specify the name of the non-editable column which will be created in the Discussion Board List if (oField.Title == "LastRepliedBy")
      2. In File: Class1.cs ; Method: ItemUpdated; specify the name of the non-editable column (as mentioned in Point 1a(i) ) properties.ListItem["LastRepliedBy"] = oUser.ID;
    2. Once the above mentioned changes are done, compile/build the code (Note: Check if the strong name is assigned to the assembly)
    3. Install the compiled dll in the GAC
  2. Now, Open the console application project: ConsoleApplication1 in Visual Studio 2005 or later version

    1. Make necessary changes here in the code: (in Program.cs file)
      1. Specify your site URL here: using (SPSite oSite = new SPSite("https://anjalich11:2001"))
      2. Specify the name of the Discussion Board here: SPList oList = oWeb.Lists["Team Discussion"];
    2. Once the above mentioned changes are done, compile/build the code
    3. Run the console application.
  3. Restart IIS

  4. Add the non-editable column in the Discussion Board (Note: Its case sensitive; so specify the exact name as mentioned in Point 1a(i) )

  5. Now try adding the topics and its respective replies in the discussion board.

  6. Check the value of the column “LastRepliedBy”.

     

Sample_Files.zip