Tuesday, July 29, 2014

Display Created by fields in Custom SharePoint List

One challenge to getting a custom form to display what you want is understanding the eccentricities of SharePoint Designer and the SharePoint storage.  I had a custom list which needed to display the created by and modifed by data.  These fields needed to be displayed on the main form along with the other data items.  This information is normally parked in the footer of the form.  This can be done by using the SharePoint:CreatedModifiedInfo  control item.  One thing to note is that the fields in Sharepoint are stored internally with different names:

Created By = @Author
Modified By = @Editor

Code to add to your custom form:

<tr>
         <td valign="top" class="ms-formlabel"><nobr>Created by</nobr></td>
         <td valign="top" class="ms-formbody">
             <SharePoint:CreatedModifiedInfo ControlMode="Edit" runat="server">
             <CustomTemplate>
                 <SharePoint:FormField FieldName="Author" runat="server" ControlMode="Display" DisableInputFieldLabel="true" /><br/>
                 <SharePoint:FieldValue FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
             </CustomTemplate>
             </SharePoint:CreatedModifiedInfo>
         </td>
     </tr>

No comments:

Post a Comment