SharePoint: Using the SharePoint Object Model with InfoPath Form Code Behind Part 3 of 2

Like the Spanish Inquisition,

“Our chief weapon is surprise…surprise and fear…fear and surprise…. Our two weapons are fear and surprise…and ruthless efficiency……”

In part 1 of this 2 part series we created an InfoPath form which used the SharePoint Object Model in it’s code behind to create new Task list items.

In part 2 of this 2 part series we published this InfoPath form to SharePoint and hooked it into the SharePoint user interface by using a content editor web part to create an HTML link to the browser form.

In part 3 of this 2 part series I conducted  a small experiment to see how one could have this InfoPath form replace the default NewForm.aspx called when adding task list items.

If you were doing this in a production setting, you could quite easily specify the URL of a custom NewForm page called to add new list items, and there are plenty of articles available for custom list form pages.

For more infomation on understanding how SharePoint List form pages work, check out Hristo Pavlov’s excellent article.

In my experiment I simply edited the NewForm.aspx page of the Tasks list using SharePoint Designer, and inserted the following piece of JavaScript into the markup (line breaks added for clarity).

<script type="text/javascript" language="javascript">

Quite simply, the javascript does an instant redirect to the URL of our InfoPath form when the NewForm.aspx pages loads, surprisingly or not it works very nicely.

Possibly a handy technique for quick List form replacements, maybe even User Editable List forms (shudder :-)) ?????

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.