Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a (sandbox) solution with some custom forms.

If I deploy it to a site that never had this solution installed before, everything works fine. However, every time I deploy it again, custom forms get "doubled". That is, a "new foo" custom form will have the save and cancel buttons on top, then the input fields, then the save and cancel buttons again on the bottom. But below those, another set of save and cancel buttons, all the input fields again, and then another set of buttons.

I've checked with a colleague that simply deactivating and reactivating the feature containing the form causes it to re-append to itself.

In other words, for the first time the feature is activated, the form looks like this:

[Save] [Cancel]
Fields
[Save] [Cancel]

If after that I deploy the solution, say, two more times, it'll look like this:

[Save] [Cancel]
Fields
[Save] [Cancel]
[Save] [Cancel]
Fields
[Save] [Cancel]
[Save] [Cancel]
Fields
[Save] [Cancel]

How can I avoid this behavior? I am aware that deleting the list that contains the custom forms prior to a new feature activation will fix the form (double checked). However, our customers will receive versions of our solution in iterations, and it's just not feasible for us to delete all their data every time a new version is rolled out.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Each custom form in lists actually contains a specific ListView web part, actually if you properly customize it, you have hidden most-likely the Default one, and added your own, for which you customize the behavior.

All this to say that actually you are dealing with provisioning of duplicate web parts, which Waldek has also explained here - http://blog.mastykarz.nl/preventing-provisioning-duplicate-web-parts-instances-on-feature-reactivation/

Basically, you need to rely on the Identifiers of your web parts during provisioning, e.g. Feature Receivers, by example, locate you list and update the Forms by code, if the web parts is in double, get rid of the oldest ones.

share|improve this answer
    
The answer in the link is correct - however, it depends on a class that cannot be used in sandbox solutions (SPLimitedWebPartManager). I have marked this as the answer, though, as people with the same problem I had, but without the constraints of a sandbox solution, will be able to benefit from it. –  Renan Apr 22 '13 at 20:31

Either as C. Marius says, hook up a Feature Receiver and clear out webparts before readding them again.

Or, If you have not made any changes to the feature, but on deploy it always gets reactivated, even though you do not want it to, you need to change the Property

ActivateOnDefault

on the feature in Visual Studio to

No Activation

A combination of the two (this an Marius one) is probably preferable.

share|improve this answer
    
We will be doing a lot of changes to the feature, unfortunately, and it has to be activated everytime :( –  Renan Apr 22 '13 at 20:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.