Have you nuked your NewForm.aspx page in Sharepoint WSS/MOSS 2007? This can happen if you remove the default list web part from the page and save the file. The problem is apparently that any time you create a custom list form web part, it grabs the latest fields from NewForm.aspx not from the list settings. Go figure.
So without warning you can totally destroy your NewForm page and also cause problems for every custom form you might spawn off of it. To save yourself from this disaster (which should not be possible in the first place IMO) follow the instructions below (these instructions were originally posted by David Szabo here):
- Open NewForm.aspx and EditForm.aspx in Sharepoint Designer
- Copy the code for the ListFormWebPart control from the EditForm.aspx. The code in question reaches from
<WebPartPages:ListFormWebPart runat=”server” __MarkupType=”xmlmarkup” WebPart=”true” __WebPartId=”{YOUR_GUID}” >down to</WebPartPages:ListFormWebPart>
- Paste it into the broken NewForm.aspx, I pasted it right below the Line:<WebPartPages:WebPartZone runat=”server” FrameType=”None” ID=”Main” Title=”loc:Main”><ZoneTemplate>
- Within the pasted lines of code look up the lines starting with<ControlModeand
<FormType
In the “Control mode” tag replace the “Edit” with “New”, in the “FormType”-Section replace the digit “6” with “8”.
- Before saving, you have to generate a new GUID for the pasted control in your NewForm.aspx otherwise your EditForm.aspx will be broken after saving!!!There are online GUID generators on the internet so you don’t need Visual Studio, e. g.:http://www.somacon.com/p113.php
Generate a new GUID and asign it to the “__WebPartId” attribute in the very first line of code of your control:
<WebPartPages:ListFormWebPart runat=”server” __MarkupType=”xmlmarkup” WebPart=”true” __WebPartId=”{YOUR_NEW_GUID_HERE}” >
- Look up the <ID></ID>-Tag further below (it was about 27 lines below in my case) and change a random number in the ID, e. g.Before: <ID>g_092cc5f1_f97c_408b_bf66_c7b235af38f9</ID>After:
<ID>g_092cc5f1_f97c_408b_bf66_c7b235af38f5</ID>
- Save your work…and your done!
Thank you to David for posting the solution. This definitely helped with some issues we had this week. I really should have known better but I was operating under the assumption that I did not at any point need to use the standard NewForm.aspx page any longer. What I didn’t realize was that once you overwrite the file it becomes the new site definition. This means you cannot simply right-click and “reset to site definition” as you might expect. You might be familiar with this if you have customized your default.aspx page and would like to restore it.
I also didn’t realize that when you make changes to your list they will not show when you re-add the Custom List Form control (see below).
To ensure this doesn’t happen when you create custom forms in Sharepoint 2007 do the following:
- Create a copy of NewForm.aspx (or right-click and select New From Existing Page)
- Remove or hide the default list web part
- From the menu select Insert->Sharepoint Controls->Custom List Form
- Select the appropriate list (the defaults should be for a new form)
- Hit Okay
Now you just need to make sure that any links pointing to NewForm go to your new page. But in this way you don’t have to worry about screwing up your NewForm page and any subsequent custom forms you may derive from it.
Alternatively you can indeed customize NewForm and make it work, just make sure you hide the default part rather than deleting it.
Thank you so much. I have a custom list with a VERY complex workflow and didn’t fancy re-building that 🙂
Thank you! This saved my butt.
Heyyy man!!! you just saved my life!!!!
I used to think that this was imposible to do…
OMG, you saved me!!!
This worked perfectly! Sure beats deleting and recreating the list, especially when workflow was involved!
Will this technique work if you nuked your EditForm.aspx instead?
Before you do all this – check the setting in the lists properties – that the “New form” is set correctly. It could be that simple.
Thanks Dave, this helped out with a legacy 2007 farm we have at work this week!