There was a business requirement to customize a NewForm.aspx page for a list to remove some of the fields shown to a user when they enter a new item into a list. To fulfill this requirement, SharePoint Designer was used to open the NewForm.aspx page and hide the existing ListFormWebPart and add a new DataFormWebPart that could be customized.
The error is generated from form.js in the ShowPartAttachment method where it is trying to set focus on the control with an ID of fileupload0, but that control is hidden as it is part of the ListFormWebPart. If the ListFormWebPart is completely removed from the customized page, then the user receives a more user friendly error generated from some error trapping code in the ShowPartAttachment method.
The issue is that although the DataFormWebPart provides the menu item and link to attach a file, it does not render the necessary client side code to support the file upload functionality.
Steps to Reproduce:
- Create a list on a site and add a few custom columns
- Using SharePoint Designer, open the NewForm.aspx page associated with the newly created list
- Either hide or delete the existing ListFormWebPart, depending on the desired results (see screen shots above)
- Insert a new DataFormWebPart
- Click Insert –> SharePoint Controls –> Custom List Form
- Choose the list to use (same list created in step 1)
- Under Type of Form to Create, select New item form
- Check the box for Show standard toolbar, if it’s not already checked
- Click OK
- Save NewForm.aspx
Navigate to the page in a browser and click on Attach File to observe the behavior described above.
two three options to work around this issue.
- Within the customized form, hide the Attach File functionality. In the above case where the NewForm is modified, we would hide the Attach File, but then add a message informing the user that in order to attach a file to the item they need to edit the item after it’s saved (assuming EditForm.aspx was not also modified as described above.)
- Another option was sent in to me via email by AutoSponge. “I start the user off with NewForm as only an upload attachment page.
Whether they upload or not, if they click ok, it creates a new item
and they are redirected to the custom edit page.” See the details here.