Monday, 5 May 2014

A Web Part with this ID has already been added to this page - Creating SharePoint App

I started with creating my first ever SharePoint App for SharePoint Online following this link. However, on trying to deploy my App I received the following error -

"A Web Part with this ID has already been added to this page".

I tried removing the web part (XSLT List View Web Part) and redeploying (please note that I was using NAPA for my development here) but that didn't work

I found this interesting blog post after Googling around and I appreciate the effort put in my Dragos here. According, to the post the reference of the Web Part is stored in the Content Database in the AllWebParts table mapped with the page on which it is placed. Usually, we add a web part to the SharePoint page using the SharePoint UI and delete it the same way. This would definitely add/delete the reference of the web part from the Content Database as well. However, since I was adding and removing the reference of the web part through HTML in my app, this would obviously not trigger the database for updating the reference.

Now, as I mentioned earlier, I am using SharePoint Online and therefore, cannot interfere with the database, so Dragos' solution would not work for me and as it is interfering with the SharePoint Content Database is out of limits.

So, since I could not delete the reference of the web part mapped against my page, I changed the name of my page and redeployed. And it worked!

Doesn't really help much if you are starting with a new app, but can save a lot of time if you have already implemented major functionality in your App. Either ways, it is interesting to understand the internal functioning of SharePoint.

Once again, really appreciate the MSDN Link and Drago's Post,

No comments:

Post a Comment