Wednesday, October 18, 2006

SharePoint Quick and Dirty Online Forms..

One of the quickest SharePoint Tricks I love to show people is how you can take an existing form and turn it into a Customized form that they can use online. You know when you look at all those paper-base forms that have "For Office Use Only" stamped on the bottom? Well we can do something similar with custom sharepoint forms. No, I don't mean we can add "For Office use only" to all our forms.. what I mean is that we can hide certain fields from the end user. So when they fill out a form we can hide all the "for office use only" fields from the end user and we can fill them in later. This is a very simple process and it can be very quick to implement.

Lets say you wanted to allow people to log a (pseudo) HelpDesk ticket to have some work done. You could start with a "Task List", but you probably don't want the user to "assign" the task to the IT staff member, or set the "Priority" of the job. So you can simplify the "NewForm.aspx" by removing a bunch of fields. These fields will still be viewable on the "EditForm.aspx", so who ever is watching the list can "assign" and "prioritize" the "job".

The process is pretty simple in SharePoint 2003 (SPS or WSS v2):

1. Create a Task List called "HelpDesk". Start with a Custom List or extend an existing "Task" list.
2. Click the "New Item" button.
3. When the NewForm.aspx loads, click the "File" Menu and select "Edit with Microsoft Office FrontPage".
4. Right click anywhere on the form and select "Customize SharePoint List". Although the form might look like it has been broken it is actually editable. You can now use FrontPage to edit the sharepoint form like you were editing any old html file.
5. So go ahead and change the layout, remove fields by selecting them and pressing the delete button. You can even add your own "Help" or "Print Preview" buttons. If you make a mistake you can always "right click" and select "Revert sharepoint list". This will return the form to its orginal state, minus any broken bits.. (See special Note below).
6. Once you have customized the form you can save it as a differnt name. For example we may choose to call the file "NewRequest.aspx".
7. When you fill out the "NewRequest.aspx" form it will still submit the information to the list.
8. Take the link to the "NewRequest.aspx" and post it somewhere on the portal home page with a title like "Submit a Request to IT".
9. You can now place an alert on the list and you will be notified when anyone fills out the "NewRequest.aspx" form.

Tip: The default action when the user saves the "NewRequest" is for the browser to return to the default view for the list. This is typically not a good thing, because people might be able to read entries in the list. So a handy trick is to add the "Source" parameter to the end of the "NewRequest.aspx" URL. The "Source" parameter can be used to specify where the user should be sent once they have completed the form. So we might have a link that looks like this:

http://intranet/lists/ITHelpDesk/NewRequest.aspx?Source=http://intranet/

Notice the "?Source=http://intranet/". This will return the user to the intranet home page. This of course could be any page on the intranet, perhaps even a "thank you" page.

Common "Gotcha": Make sure that you do not remove any "required" fields, because if the user can not enter data into the field the form will not submit while "required" fields still contain no data.

Note: One thing to watch out for is the "Attachments" cells. These cells have specially named tables and cells in them and if you duplicate them or delete them then you will see JavaScript errors in your form when you start using them. The can be fixed but it is usually easier to "revert" the form and start again.