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.

5 comments:

The easiest thing to do in this case is to insert a new custom list form - it will have all the columns - and copy the apropriate "tr" from the new one to the old one, and then safely delete the new one.Cheers!

Hello,When I copy the code for the field from the new temporary custom form into the original form with all the other edits, the field does show on the form, but I cannot click on the drop-down to select an item. Have you encountered this?

Note the last line of the second paragraph above: Verify that the field name is in the section in the top of the web part code, just above the XSL. If not add it following the format of the existing fields.