Monday, February 21, 2011

Interesting List definition issue

Hi All,

I was working on some list definition stuff and I created a list of type tasks from user interface. Now I went ahead and created the list definition schema from list definition generator tool. Well, it generated very well. What I had done in the list definition is that I have attached the event handler to that list. I had item added event attached to it. I deployed that list definition and I worked perfect.

The only problem I faced was when I created couple of more lists of type tasks from user interface, I ran into a problem. Well every time I add item to any of the list which was created as a type tasks. My event handler used to get triggered.

Now that’s interesting. I had to look for the solution but before that I had to look for the problem. I tried thinking couple of minutes and bingo I got the problem.

Well the problem was I created the list definition from the type of tasks, hence I t actually registered the event handler to the task type’s of list. So any list of type task has automatically attached handlers with that. Interesting right? Yes, but that was the case.

Now the solution part comes in to the picture. The solution is just give the unique integer ID to the ListType in schem.xml file and use that ID while registering in to the elementmenifest.xml file.

If you are registering the handler from the code by fetching the list name, then I think this issue should not come. However if you are going to take list definition route to have handlers attached to it when list gets created, then better to have new ID as mentioned above.

One more day, one more challenge and one more pleasure to solve it.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com