Thursday, January 14, 2010

Adding Columns to a Custom List Form in SharePoint Designer

A previous post showed how to customize a SharePoint form using the Custom List Form. The down side to customizing your form is that if you need to add a new column to the list it will not be automatically added to the form. You must go into SharePoint Designer and edit the form code, manually adding the item back in.

The easiest route is to start by copying the code for a similar field and change the variable names to match the name of your new column.
The id number will likely start with ff and need to be unique, one greater than the current highest number. The id number appears again in the designer:bind section and the FieldDescription id. It must match in all three spots.
The column name appears in the FieldName fields and the designer:bind section. Spaces in the column name are represented by _x0020_
Verify that the field name is in the <datafields> section in the top of the web part code, just above the XSL. If not add it following the format of the existing fields.

Another option would be to delete the Custom List Form and create a new one. Assuming you've modified the Custom List Form you would need to recreate any modifications, but if they are minor that might not be difficult.

A third option would be a combo of the two above options. First make a copy of the page that the Custom List Form appears on. On that copy delete the Custom List Form and then add it back. Go into the code, copy the code you need, and paste it into the Custom List Form on the original page. When you are finished delete the copy.