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>
This missive records my trials and tribulations as I code my way through projects. Fix the problem once and reuse the solution!
Showing posts with label Modified By. Show all posts
Showing posts with label Modified By. Show all posts
Tuesday, July 29, 2014
Custom Edit List Form Modified By field is blank -
Custom Form Does Not Display “Created By” value
I was customizing a sharepoint list today and customer asked for a modification to the New and Edit forms for the list. I was using Designer to accomplish the task and was able to get most of it working. The customer had asked for a field on the edit form to show the Modified by field. This is the standard canned field which is part of every list in SharePoint. I thought no problem I just get the internal field name and use the <xsl:value-of select="@Editor"/>.
Challenge:
Each time I would load the edit form the field would resolve to empty. This made no sense and really drove me crazywhile I tried to understand the problem.
Sample:
<tr>
<td valign="top" class="ms-formlabel" width="190px">
<H3 class="ms-standardheader">
<nobr>Modified By</nobr>
</H3>
<!--Always Blank --/>
<xsl:value-of select="@Editor" disable-output-escaping="yes"/>
</td>
<td valign="top" class="ms-formbody" width="400px">
<SharePoint:FormField runat="server" id="ModifiedByID" ControlMode="New" FieldName="Editor" __designer:bind="{ddwrt:DataBind('u','ModifiedByID','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Editor')}"/>
<SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Editor" ControlMode="Edit"/>
</td>
</tr>
Solution:
It helped me to look at the entire form and pay close attention to the syntax for the FormField control.
This includes the attribute ControlMode. This tells the form control what state it is currently in. (New,Edit,Display) The key mistake I had made was to set this controlmode attribute to New instead of Edit.Once I set the controlmode attribute to Edit the value began to be passed to the form and displayed.
Corrected:
<tr>
<td valign="top" class="ms-formlabel" width="190px">
<H3 class="ms-standardheader">
<nobr>Modified By</nobr>
</H3>
<!--Always Blank --/>
<xsl:value-of select="@Editor" disable-output-escaping="yes"/>
</td>
<td valign="top" class="ms-formbody" width="400px">
<SharePoint:FormField runat="server" id="ModifiedByID" ControlMode="Edit" FieldName="Editor" __designer:bind="{ddwrt:DataBind('u','ModifiedByID','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Editor')}"/>
<SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Editor" ControlMode="Edit"/>
</td>
</tr>
I was customizing a sharepoint list today and customer asked for a modification to the New and Edit forms for the list. I was using Designer to accomplish the task and was able to get most of it working. The customer had asked for a field on the edit form to show the Modified by field. This is the standard canned field which is part of every list in SharePoint. I thought no problem I just get the internal field name and use the <xsl:value-of select="@Editor"/>.
Challenge:
Each time I would load the edit form the field would resolve to empty. This made no sense and really drove me crazywhile I tried to understand the problem.
Sample:
<tr>
<td valign="top" class="ms-formlabel" width="190px">
<H3 class="ms-standardheader">
<nobr>Modified By</nobr>
</H3>
<!--Always Blank --/>
<xsl:value-of select="@Editor" disable-output-escaping="yes"/>
</td>
<td valign="top" class="ms-formbody" width="400px">
<SharePoint:FormField runat="server" id="ModifiedByID" ControlMode="New" FieldName="Editor" __designer:bind="{ddwrt:DataBind('u','ModifiedByID','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Editor')}"/>
<SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Editor" ControlMode="Edit"/>
</td>
</tr>
Solution:
It helped me to look at the entire form and pay close attention to the syntax for the FormField control.
This includes the attribute ControlMode. This tells the form control what state it is currently in. (New,Edit,Display) The key mistake I had made was to set this controlmode attribute to New instead of Edit.Once I set the controlmode attribute to Edit the value began to be passed to the form and displayed.
Corrected:
<tr>
<td valign="top" class="ms-formlabel" width="190px">
<H3 class="ms-standardheader">
<nobr>Modified By</nobr>
</H3>
<!--Always Blank --/>
<xsl:value-of select="@Editor" disable-output-escaping="yes"/>
</td>
<td valign="top" class="ms-formbody" width="400px">
<SharePoint:FormField runat="server" id="ModifiedByID" ControlMode="Edit" FieldName="Editor" __designer:bind="{ddwrt:DataBind('u','ModifiedByID','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Editor')}"/>
<SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Editor" ControlMode="Edit"/>
</td>
</tr>
Subscribe to:
Posts (Atom)