Skip Ribbon Commands
Skip to main content

Point2Share | Daniel McPherson's SharePoint Blog

:

The zevenseas Community > Blogs > Point2Share | Daniel McPherson's SharePoint Blog > Posts > The IgnoreIfAlreadyExists File Element Attribute
April 26
The IgnoreIfAlreadyExists File Element Attribute

This attribute doesn't quite work the way I expected it to, or the way I have seen it described in other places on the web. (The documentation is not as clear as it should be. I really wish it did work the way described in Chris's great post!)

From the official documentation (http://msdn2.microsoft.com/en-us/library/ms459213.aspx) we find that it is designed to:

IgnoreIfAlreadyExists

Optional Boolean. TRUE to provision the view even if the file already exists at the specified URL; otherwise, FALSE.

To fully understand how this attribute worked I set up the following test:

  1. Created a Feature (ReplaceTest1) which simply provisioned a file (test.aspx) into a team sites /_catalogs/masterpage folder. The file simply contained "11111111".
  2. I then tested this and confirmed that it worked correctly, I saw "11111111" when accessing the page.
  3. I then created another feature (ReplaceTest2) based on ReplaceTest1, except with:
    1. A new FeatureID
    2. I added the IgnoreIfAlreadyExists parameter, and set it to TRUE
    3. Modified the test.aspx file to contain "22222222" instead.
  4. I then activated this feature, and in doing so found that it didn't actually replace the existing test.aspx file. In the browser I still saw "11111111". I didn't expect this.
  5. I then decided to change ReplaceTest2 so that IgnoreIfAlreadyExists was equal to FALSE
  6. I then repeated the tests and found that this time, when activating ReplaceTest2, I received an error telling me that the file already existed. I did expect this.

So, in summary, it appears this attribute actually does exactly what it says (even if it really could have said it clearer), it ignores the provisioning of the file if a file with the same name already exists. At this point I have to wonder just how useful such an attribute really is!

Anyway, I'm going to return to investigating the easiest way to replace an existing file via a feature, but if anyone out there has had a different experience then I would love to hear about it.

Comments

Kurt

Hi Daniel, at the moment I am struggeling with the same problem. Please post your solution when you find out how to overwrite an existing file in the MasterPages catalog with a feature. I actually have problems overwriting files from the same feature (same FeatureID)...
Daniel McPhersonNo presence information on 16/11/2008 07:05

Markus

I have same problem. Seems Microsoft doesn't make any bugs - otherwise they would think about deploying an upgrade, hotfix, new version, ...
Daniel McPhersonNo presence information on 16/11/2008 07:05

Nicolas

Same problem here... But it's really urgent si I think I'll have to customize my page layout in SPD, eeek ! :(
Daniel McPhersonNo presence information on 16/11/2008 07:05

Vivek Soni

System Account on 05/07/2009 10:42

mahavir patil

So the fact is, there is no easy way to achieve it. You have to have Feature Event Receiver to do the stuff. Refer the below link for further help:
http://kartooz.wordpress.com/2009/03/23/how-to-overwrite-sharepoint-master-page-using-a-feature/
System Account on 25/07/2010 20:51

Add Comment

Title *


Body *


CommentUrl


CAPTCHA *

 

Attachments

 

 Statistics

 
Views: 1994
Comments: 5
Tags:
Published:1644 Days Ago