Lots of bad things can happen with variations. The main point is: you can, for some reason, move or delete a site/page in one of the labels and the system will get corrupted.
The most typical cases I found were: deleting a site in a secondary label, then later trying to recreate that label variation of the site (which has subsites). Some of the subsites wouldn't be created, since there was still some garbage in the Relationships List from the previous entries (that got deleted).
Be very careful when messing with this hidden list. After deleting some wrong entries of the subsite/pages, I managed to recreate it. A tip: look for the name of the page specifically, since I found entries that were misplaced in the Pages library of the parent site. Apparently because of the first failure, when the procedure failed to create the variation of the subsite (I'm not sure about this one, but I doubt the page was ever created in that place).
There is also a great program, by Tim Dobrinski, called Variations Editor, available here on CodePlex and described here by him. It will check for problems with variations through your portal. It seems very efective. After detecting the errors, it also makes suggestions on how to fix it and can directly apply the fixes on your portal. It doesn't seem to detect the above situation (list entries of pages that no longer exist), but it will detect any incoherent behaviour in the data found about existent pages.
Great tool!
Monday, March 22, 2010
Wednesday, March 17, 2010
Re-activating a feature with scope Web
Ever had a feature activated in several subsites, needing to be re-activated?
Uninstall / install feature will not work. But this command from Gary Lapointe will: gl-activatefeature (more information here).
It will perform the deactivate and activate in all subwebs, if you provide the command with the base site collection url. You can also define that only the webs with the feature already activated will have this re-activation done (using -ignorenoactive).
(Yet another) great command!
Uninstall / install feature will not work. But this command from Gary Lapointe will: gl-activatefeature (more information here).
(Yet another) great command!
ErrorWebPart instead of SummaryLinkWebPart
I was working with some custom development where I needed to import some webpart from a top level page. This was done in 2 stages:
- it would start as the execution of a user button's action, i.e. the user would have a page to explicitly execute some code, including the webpart import.
- some event handlers would also trigger this same action, i.e. whenever someone checked in a pre-determined page.
In the first case, everything went fine. The webparts were successfully imported.
In the second case, the SummaryLinkWebPart would not be imported. Actually, the SPLimitedWebPartManager would not return a SummaryLinkWebPart, but a ErrorWebPart. It was a customized SummaryLinkWebPart, with a non-default MainXslLink, ItemXslLink and so on...
Apparently, the SPLimitedWebPartManager (or the SummaryLinkWebPart) need to have a request/context set in order to create/return the correct WebPart. Since in an Event Handler (or Timer Job) those objects are not created by default, it would return you that error object.
To make things worse, my code would return a "No parameterless constructor" exception on that ErrorWebPart, which got me in the wrong way to start with.
How to solve it? Just create the necessary objects, before getting the webparts from the SPLimitedWebPartManager:
HttpRequest request = new HttpRequest("", destinationWeb.Url, "");
HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter()));
HttpContext.Current.Items["HttpHandlerSPWeb"] = destinationWeb;
where destinationWeb is the web where the page you are importing webparts to is located (and perhaps it can actually be any web).
Don't know what really happens inside the Microsoft code to cause this behaviour, but I'm guessing it is some use of SPContext.Current to get a SharePoint object (like CurrentWeb).
Best SharePoint links
- SharePoint Automation, by Gary Lapointe.
(currently being edited with my favorite resources)
Friday, March 12, 2010
Stupid things in SharePoint 2007 API
For future reference:
- ItemDeleted event receiver has no information whatsoever on the item that was deleted (quite useful then!)
- SPWeb.GetFile(string) returns a SPFile object without the correct data (namely Exists and Length properties); using SPWeb.GetFileOrFolderObject(string) on the other hand, after instantiation, does return a valid and correct SPFile object
- Also on the previous topic, you should always use the web where your file is! Using RootWeb may or may not work well (I have experienced this!). In my case, I was using RootWeb.GetFileOrFolder() / RootWeb.GetFile() and then file.OpenBinary() would return as exception of File Not Found. Using FileWeb.GetFileOrFolder() worked perfectly! As a confirmation of the strange behaviour, in an external console app, RootWeb.GetFileOrFolder() was working!
- Event Handlers and Timer Jobs do not have request/context objects, that can sometimes be needed so that API methods work correctly and return what you expect (see this post)
(updated everytime I find "funny" things)
TechDays 2010 Lisbon, Road to SharePoint 2010, and more!
I will attend TechDays 2010 Lisbon, 20-22 April. I will try to attend every SharePoint session, and some Visual Studio ones too.
Another great initiative (that unfortunatelly I have not been attending), also for portuguese people, is Road to SharePoint 2010. Some good presentations already have their slides there. Not close to being in the presentation itself, but worth looking into.
There is also a great portuguese community site, Portuguese SharePoint Community, recommended to all portuguese SharePoint developers/architects out there!
Thursday, March 11, 2010
Google maps tips
Getting the current langitude and latitude of the map center while in Google Maps is always useful, just put in your browser's location url: javascript:void(prompt('',gApplication.getMap().getCenter()));
I have also been using clustering to show a set of gmarkers on the map, so that zooming in/out still gives us interesting information, instead of just a bunch of markers all over the place. The library we used was this one: http://googlegeodevelopers.blogspot.com/2009/04/markerclusterer-solution-to-too-many.html. Really good!
Enjoy.
I have also been using clustering to show a set of gmarkers on the map, so that zooming in/out still gives us interesting information, instead of just a bunch of markers all over the place. The library we used was this one: http://googlegeodevelopers.blogspot.com/2009/04/markerclusterer-solution-to-too-many.html. Really good!
Enjoy.
Monday, March 8, 2010
SharePoint 2010 oficial release - May 12th
Microsoft has announced the official release of the new SharePoint version, in the Microsoft SharePoint Team Blog, in this post by Arpan Shah.
This should be a very interesting landmark.
I've been quite busy in a MOSS 2007 project, but I'm planning to get my hands on 2010 in the next few weeks and also attend TechDays 2010, here in Lisbon. From what I've seen, it seems like another huge step for SharePoint, both from the user point of view, but also (this time) for the developer too. Let's hope everything is as nice as it seems at first look.
I only saw some webcasts from Microsoft people, so I think that it might be in fact a great improvement for developers, but I'm guessing (like in 2007) there will still be many tricks to learn, not before some hours of pain. Let's pray for me to be wrong.
This should be a very interesting landmark.
I've been quite busy in a MOSS 2007 project, but I'm planning to get my hands on 2010 in the next few weeks and also attend TechDays 2010, here in Lisbon. From what I've seen, it seems like another huge step for SharePoint, both from the user point of view, but also (this time) for the developer too. Let's hope everything is as nice as it seems at first look.
I only saw some webcasts from Microsoft people, so I think that it might be in fact a great improvement for developers, but I'm guessing (like in 2007) there will still be many tricks to learn, not before some hours of pain. Let's pray for me to be wrong.
Subscribe to:
Posts (Atom)