Manage Created & Modified info on custom form in XSLT
Just wanted to write this down so I don’t forget how to do this, if this helps someone else out even better!
If you’re wanting to access the Created By, Created On, Modified By and Modified on information on a custom list form in SharePoint 2010 or 2013, you can do this using the SharePoint:CreatedModifiedInfo control and use the CustomTemplate element, like so:
<SharePoint:CreatedModifiedInfo ControlMode="Display" runat="server">
<CustomTemplate>
<SharePoint:FormField FieldName="Author" runat="server" ControlMode="Display" DisableInputFieldLabel="true" />
<SharePoint:FieldValue FieldName="Created" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
<SharePoint:FormField FieldName="Editor" runat="server" ControlMode="Display" DisableInputFieldLabel="true" />
<SharePoint:FieldValue FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
</CustomTemplate>
</SharePoint:CreatedModifiedInfo>
SharePoint uses the field names Author, Created, Editor and Modified to refer to the following:
Author: Created by
Created: Date Created
Editor: Modified by
Modified: Date last modified
You can include any combination of these fields and any other HTML/CSS to adjust the layout as needed either inside or outside of the CreatedModifiedInfo control. If you want to separate out the fields into separate areas of the page, you will need to repeat the control pattern of SharePoint:CreatedModifiedInfo->CustomTemplate->FormField for each section.
Hope this helps!
4 thoughts on “Manage Created & Modified info on custom form in XSLT”
Have you tried this for your date field?
This will convert your date to a more traditional format, like mm/dd/yyyy hh:mm. A complete listing of formats and country code examples can be found at http://blogs.msdn.com/b/joshuag/archive/2009/03/25/custom-date-formats-in-sharepoint-xsl.aspx.
No, I haven’t tried that. How would I can incorporate that into the ‘CustomTemplate’ code in your post?
Sorry for the delay…You can add that code snippet above to any area of your custom list form inside of the tags. Just replace the @Datefield with the actual name of your field you want to display.
Thanks for the tip.
I found I needed to use FieldValue for Author and Editor instead of FormField otherwise nothing would display.
Also the date fields (Created/Modified) displayed in the wrong timezone … looked like everyone was updating stuff at 1am! Any ideas?
Comments are closed.