none
Assign Recent Comment to XSL Variable

    Question

  • When you have a SharePoint list with versioning and a comments field that appends, is there a way to assign the most recent comment to an XSL Variable?

    For Example:  <xsl:variable name="LastComment" select="@Comments(0)" />

    or something like that...

    Thanks

    -Harry

    Monday, April 09, 2012 7:42 PM

Answers

  • Hi Harry,

    Sorry for misunderstand you.

    Here are 2 workarounds for you:

    1. Use SharePoint AppendOnlyHistory control. But all versions for the commands field will display. (Replace the commands with you multiple field name.)
      1. Add following code if you are using XSLT list view web part.
        <SharePoint:AppendOnlyHistory runat="server" FieldName="commands" ItemId="{$thisNode/@ID}" ControlMode="Display" />
      2. Add following code if you are using Data View Web Part.
        <SharePoint:AppendOnlyHistory runat="server" FieldName="commands" ItemId="{@ID}" ControlMode="Display" />
    2. Disable the Append Changes to Existing Text option for commands field. Create another multiple line type of field, and enable Append Changes to Existing Text option for this column. Update the second multiple field with commands fields when commands field is changed or new created using workflow.
      For the detail steps, please see following blog.
      http://sharepoint-ravi.blogspot.com/2010/11/append-changes-to-existing-text-feature.html

    Thanks & Regards,
    Emir


    Emir Liu

    TechNet Community Support

    Thursday, April 12, 2012 12:02 PM

All replies

  • Hi Harry,

    Do you mean that you have a list which is enabled item version history and content approval options? So you have a Approver Comments field and what to get the latest Approver Comments value from all list items in that list?

    If so, please try the following XSLT.

    <xsl:variable name="countcomments" select="count(/dsQueryResponse/Rows/Row[@_ModerationComments!=''])" />
    <xsl:value-of select="/dsQueryResponse/Rows/Row[@_ModerationComments!=''][$countcomments]/@_ModerationComments" />

    Let me know if I misunderstand you.

    Thanks & Regards,
    Emir


    Emir Liu

    TechNet Community Support



    Wednesday, April 11, 2012 7:27 AM
  • Hello Emir

    Not quite.  I have a list with version history enabled.  However, Content Approval is NOT enabled so I'm not really looking for the latest approver comments.  In my list I've defined a field of type Multi Line Text box, where I have the "append changes to existing text" flagged as "Yes".  I'm looking for the latest value entered in this multi line comments box.

    Thanks for your help.

    Wednesday, April 11, 2012 8:41 PM
  • Hi Harry,

    Sorry for misunderstand you.

    Here are 2 workarounds for you:

    1. Use SharePoint AppendOnlyHistory control. But all versions for the commands field will display. (Replace the commands with you multiple field name.)
      1. Add following code if you are using XSLT list view web part.
        <SharePoint:AppendOnlyHistory runat="server" FieldName="commands" ItemId="{$thisNode/@ID}" ControlMode="Display" />
      2. Add following code if you are using Data View Web Part.
        <SharePoint:AppendOnlyHistory runat="server" FieldName="commands" ItemId="{@ID}" ControlMode="Display" />
    2. Disable the Append Changes to Existing Text option for commands field. Create another multiple line type of field, and enable Append Changes to Existing Text option for this column. Update the second multiple field with commands fields when commands field is changed or new created using workflow.
      For the detail steps, please see following blog.
      http://sharepoint-ravi.blogspot.com/2010/11/append-changes-to-existing-text-feature.html

    Thanks & Regards,
    Emir


    Emir Liu

    TechNet Community Support

    Thursday, April 12, 2012 12:02 PM