maandag 9 november 2009

Preset form values in SharePoint 2007

My current customer is implementing a new system that is currently using a Windows help file (.hlp) to provide help/workinstructions for a specific form or field in that application. In the current situation, a user is presented with a static help article when F1 is pressed. Because it's difficult to maintain this help file, we decided to migrate these help/workinstructions to a Microsoft SharePoint Wiki library. Together with an approval workflow, it's easier to maintain the content of the help library.

In the new situation, a browser instance is started when a user presses F1, referring to the SharePoint portal. The ID's related to the window or field where the user pressed the F1 key are provided through parameters in the URL. A custom webpart fetches the querystring parameters from the URL and checks with a CAML query if there are any matching Wiki articles. When a single article is found, the user is redirect to the matching article. When there are no articles found, the user is provided with a link to create a new article. The default newform page doesn’t have the ability to preset any values. Because I cannot explain to an end-user to manually enter the metadata properties for the new article, those values need to be filled in automatically according to the parameters in the URL.

I accomplished this using a brilliant javascript provided by Rob Howard, a Microsoft developer with a blog. There are some interesting comments underneath his blogpost.

CodePlex offers a solution that makes it easy to include javascript or jQuery in your SharePoint list forms, using a custom field. Unfortunately, this only works when the form pages are located in the forms folder of the SharePoint list. The form used by a Wiki to create a new article is located in the layouts folder (~/_layouts/CreateWebPage.aspx). Using ASPX forms outside the form folder of the list is not supported by this solution. In case you want to do the same for a document library or custom list, you can use this pragmatic solution.

Geen opmerkingen:

Een reactie posten