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"> window.location='http://portal/_layouts/FormServer.aspx? XsnLocation=http://portal/FormServerTemplates/TestObjectModelForm.xsn &SaveLocation=http://portal/ &Source=http://portal &DefaultItemOpen=1';</script>
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