Monday, August 30, 2010

SharePoint 2010 CQWP Modified Date

Pulling out your hair trying to find the field name for the "Last Modified Date" SharePoint 2010 field for use in ItemStyle.xsl? Here it is, with an example of how to format the date using xslt functions available to ItemStyle.xsl:

Modified On: <xsl:value-of select="ddwrt:FormatDate(string(@_x007B_28cf69c5_x002D_fa48_x002D_462a_x002D_b5cd_x002D_27b6f9d2bd5f_x007D_) ,1033 ,5)" /><br /><br />

I found the field name by dumping the names of all properties available to my xsl template using the Debug code below in ItemStyle.xsl. Once you've updated ItemStyle.xsl, create a test page in your SharePoint portal, drop in the CQWP and pick the following Debug template from the list.

<xsl:template name="Debug" match="Row[@Style='Debug']" mode="itemstyle">
        <div>
            <xsl:for-each select="@*">
                P:<xsl:value-of select="name()" /><br/>
            </xsl:for-each>
        </div>
</xsl:template>

3 comments:

J. Kevin Parker said...

This post was very helpful. Pulling my hair out indeed!

mickey911 said...

Since our upgrade from SP 2007 to 2010, this debug code is showing GUID id for KEY instead of the actual field names, in some cases. Has anyone else encountered this and if so, how did you resolve to showing all the field names without the GUIDs?

mickey911 said...

Since our upgrade from SP 2007 to 2010, this debug code is showing GUID id for KEY instead of the actual field names, in some cases. Has anyone else encountered this and if so, how did you resolve to showing all the field names without the GUIDs?