Thursday, November 09, 2006

Sharepoint list forms and adding web parts and our Sub tasks solution

Lately I have been testing adding web parts to list forms and discovered an interesting thing:

I have been involved with doing a nice solution for sub-tasks in sharepoint 2007 and the way we did it is develop a web part to put on the "display form" that queries the task list for items with the "parent task" field pointing at the current displayed task.

Adding that web part to the display form wasn't a problem - just open the form in Sharepoint designer, add a web part zone to the side and drop the new web part there.

Then I wanted to add a web part to the "new task" form, that gets from the querystring which task it should connect to, and set the value to the "parent task" field automatically. To my surprise, I found that if you try to put it on the form, the page crashes with an error.

Before you say "Ishai, you write lousy code" I have to stop you and say I tried adding default sharepoint web parts as well, and the end result of the research is that when you add web parts to a page that has either the "edit" or the "new" list forms - the page will crash.

Whats the workaround? we moved the code from a web part to a web control, and manually added it to the page. Works like a charm, and now we have a viable tasks-sub tasks solution. I will publish what I can of the code after testing.

Here is what our solution looks like:
Creating a new task:

View that task, currently no sub tasks were created:

Click the "Create sub task" link and you get to the "new task" page again:

View the root task again, this time you see the sub task in the side web part:

Another option to create the sub tasks - through a context menu:

I want to mention that two developers have been working with me on those web parts- I want to thank Adam Tibballs and Steven Pavlovic for their time and effort.

1 comment:

Bryan said...

I am new to sharepoint, doing a pilot (poc) which one of the requirments is to have subtasks. could you share the code for this?