kwizcom banner advertisement

Add New Field to Customized List Forms in SharePoint 2013

Requirement: You have customized a SharePoint list form heavily. Now you got a new requirement to add a new field to the List, of course on List form as well. Unfortunately, when you add a new column to SharePoint list, custom forms have no effect - meaning new column will not appear on custom forms in SharePoint!

So, This leads to create a new list form and do all customizations in the list form again from the scratch, isn't it? Well, Here is a trick to avoid rebuilding custom list forms when new fields are added to the list.

Step 1: Refresh the data source
  • Open your custom form (Say, New.aspx) in SharePoint designer
  • Click on "Refresh data source" link in "Data Source Details" pane. 
    • Not finding "Data Source Details" pane?
      Place the cursor under <SharePoint:DataFormWebPart> node, You'll find the "Data View Tools" Ribbon Group. Click on "Options" Tab and then click on "Data Source Details" button. This should bring the data source details pane.  
Add New column to Custom List Form in SharePoint 2013
This updates the <DataFields> node in the source code!

Step 2: Copy Paste the similar field and update Field ID and Name 
The next step is to copy paste the existing similar field (In my case its single line of text) and change the Field name and ID  field's number which start with "FF"
  • Locate a field of similar type. Copy between <TR> to <TR>. Here is my code
<tr>
 <td width="190px" valign="top" class="ms-formlabel">
  <H3 class="ms-standardheader">
   <nobr>Change Request Number</nobr>
  </H3>
 </td>
 <td width="400px" valign="top" class="ms-formbody">
  <SharePoint:FormField runat="server" id="ff50{$Pos}" ControlMode="New" FieldName="ChangeNumber" __designer:bind="{ddwrt:DataBind('i',concat('ff50',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ChangeNumber')}"/>
  <SharePoint:FieldDescription runat="server" id="ff50description{$Pos}" FieldName="ChangeNumber" ControlMode="New"/>
 </td>
</tr>
  • Paste the copied code into the relevant place. Change the Title text of the field. Change "FieldName" to new field. (Internal name of the field!). 
  • Change the ID field: Each field ID in SharePoint list form is named with the prefix "ff<Number>" such as "ff1","ff2", "ff3"and so on. Search for text "FF" in your source code. Get the highest FF number from the form. Change your pasted code's FF to existing higest FF +1. E.g. In my case, I found a field with ID: FF49. So, I changed my code to FF50.
These steps must be repeated for all custom forms such as Edit Form, Display form separately!
Add New Field to Customized List Forms in SharePoint 2013 Add New Field to Customized List Forms in SharePoint 2013 Reviewed by Salaudeen Rajack on 7:21 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.