February 22, 2012

Recover NewForm.aspx from the dead in Sharepoint 2007

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):

  1. Open NewForm.aspx and EditForm.aspx in Sharepoint Designer
  2. 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>

  3. 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>
  4. 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″.

  5. 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}” >

  6. 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>

  7. 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:

  1. Create a copy of NewForm.aspx (or right-click and select New From Existing Page)
  2. Remove or hide the default list web part
  3. From the menu select Insert->Sharepoint Controls->Custom List Form
  4. Select the appropriate list (the defaults should be for a new form)
  5. 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.

Understanding the Sharepoint CAML query

Sharepoint allows you to utilize web service calls to retrieve and manipulate data.  To do this though you will need to be able to write CAML to create your queries.  I found this site pretty useful when it came time to really dig into creating my own custom CAML-based Sharepoint queries.

Join Lists Using SharePoint Designer 2007

This is a great post on doing a join in Sharepoint, all through Sharepoint Designer w/o any code.

View the post at Yet Another SharePoint Blog

How to create a Sharepoint theme and set it up for others to use

This is a pretty common task.  But one that there may be some “mystery” around if you haven’t done it before.  It is actually pretty simple once you get under the hood.  Check out these directions to find out how to create your own custom theme (based upon an existing one) quickly and easily.

Note: when you are editing the server XML file and putting in the new entry for your images, the images folder referenced is actually up a level from your themes directory.  The existing ones start with TH (there is a ton of other stuff in that folder).  Grab an existing one to get your dimensions.

Sharepoint Designer: “The folder name is not valid” error

This is one of those random WTF kind of issues that I run into when trying to connect to Coke’s Sharepoint servers while not on VPN.  I think I have finally found a nice workaround which is painfully easy.

Instead of clicking the option to open a site via the icon or File->Open Site simply use File->Open instead.  Here enter the full path to the site/subsite you are trying to open.  Worked like a champ for me!

Sharepoint: Hiding the unhidable fields

Sharepoint allows you a lot of freedom to control what your user sees in lists throughout your site.  But if you like me have customized  not only your theme and templates, you also want to customize the forms that your users interact with.

To do this you likely are editing your NewForm.aspx and probably have a custom master page.  What you might be wondering is how on earth do you hide the Title field in forms?

Unlike other fields in a list, Title is special in that it cannot be deleted, no matter what.  You can do a few things though… you can easily hide it from your default view and you can also ensure it isn’t required.  However, this still leaves it showing when users add new items to the list or edit the list.

Check out this tutorial on how to accomplish the unpossible, hiding the Title field in your forms without any hacking.