A few days ago I started making a custom NewForm.aspx for a list with Sharepoint Designer. I started hiding the default list form webpart and inserted a custom list form. I tweaked this the way I wanted and it worked like charm. But, with testing I found out that I couldn’t upload any attachments. When I clicked the “Attach File” button nothing happens.
if (document.getElementById("part1")==null ||
var L_FormMissingPart1_Text= "This form was customized not working with attachement.";
You can see that it tries to hide part1 and shows partAttachment. In my source I found both spans, but the part1 span was holding the hidden listview webpart that was off course already hidden. This is just another bug in Sharepoint Designer.
I started searching the internet for a fix to this problem and came along a post that refers to the following hotfix for sharepoint designer http://support.microsoft.com/kb/960311 and WSS update http://support.microsoft.com/kb/951695. After applying these fixes, I recreated the custom listview. You can also manually edit an existing custom listview by applying a few lines of code that is given here http://support.microsoft.com/default.aspx?scid=kb;en-us;953271&sd=rss&spid=11373, but I recommend deleting and recreating the listview.
This however didn’t solve anything. When I looked a bit closer at the code I saw that the “part1” span was in place and it theoratically should work. After spending some hours to solve this problem I tried to delete the hidden listview, cause I thought it might interfere, and it did! It’s quite obvious because two spans with the id “part1” are on the page and it hides the first one.
We are working with Sharepoint and one typical Sharepoint issue is that when one problem is solved the next pops up. And indeed this is the case. The form worked fine when I did go to AllItems.aspx, but it now throws an error when clicking “New” in the list overview saying “Invalid page URL” and some users getting “An unexpected error has occurred”. The solution is fairly simple: just don’t delete the List Form Web Part, but I did already =|. So I copied the List Form Web Part from a backup back to the site. If you ran into the same situation but don’t have a backup, don’t bother inserting a new List Form Web Part but just copy it from your EditForm.aspx and doing some small modifications. Here are the instructions for doing this: http://blogs.msdn.com/dszabo/archive/2007/02/20/custom-list-newform-aspx-ruined-in-wss-3-0.aspx
Now when I was back where I started I just moved the custom Listview to the top by dragging and dropping in Sharepoint Designer making it the first webpart on the screen. This did solve allmost everything, I could open the new form normally and upload attachments to it.
However as I said before, when one problem is solved the next pops up. Now, when I fill the form and save it I get a brand new error:
“Failed to get value of the “Attachments” column from the “Attachments” field type control. See details in log. Exception message: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)”
The attachments of the two webparts are conflicting so I made the compiler convince that the hidden List Form isn’t a ListForm by edit the following line in the NewForm.aspx in sharepoint designer:
this way the hidden List Form is still there but doesn’t conflict. The form works perfectly fine for me now.
I found out that for the first new item in the list I cannot attach any files, because there is no “attach file” button. For any other new item it worked, but simply not the first one =S
However, there is a solution to this also. Just change the following in the NewForm.aspx and everything will work fine:
Some readers had a problem which is described as “When I try to add attachments to an existing list entry (Edit form) the file attachment dialog doesn’t close when hitting OK.”or “When i click the button to “Attach File”, I now get to the page where I can attach a file, however, after selecting a file when I click “Ok”, nothing happens and I get an “Error On Page” ”
var elm = document.getElementById(“idAttachmentsTable”);
if (elm == null || elm.rows.length == 0)
Just make a new page. in the new page, add a custom list form. Look at the code generated for the custom list form. At the bottom, it will have your attachments field that you are probably missing. Copy and paste that attachments field into your problem form and you should be good to go.
Credits go to pete w for these solutions.