Friday, June 28, 2013

Change Site Definition

When an upgrade is performed on a SharePoint environment chances are some items will get lost in the upgrade.  This is especially true if your 2007 environment took advantage of the FAB40 template set or someone went crazy downloading free site templates from the internet.  These items do not block a successful upgrade and sites may even continue to work as expected after the upgrade has been performed.  However these do leave your content databases in a weird state and central administration does warn about these missing items so it is best to cleanup your content databases to remove these broken references.  There are a number of possible errors that can be presented and for most of them the way to resolve the problem is straight forward.  For reference I have included these here.

MissingWebPart and Missing Assembly

However there is no well known process for dealing with MissingSiteDefinition references which look like this message:

[MissingSiteDefinition] 1 Sites in database [] has reference(s) to a missing site definition, Id = [75820], Lcid = [1033].  The site definitions with Id 75820 is referenced in the database [], but is not installed on the current farm. The missing site definition may cause upgrade to fail. Please install any solution which contains the site definition and restart upgrade if necessary.

The site definition does not seem to be used or depended on anywhere inside of SharePoint, it only seems to be used for loading resources from the 14 hive.  However there is no way through stsadm or powershell to change the site definition for an existing site which means once a site is created there is no way to change the site definition.  This can be very troublesome because a lot of backup / restore and import / export commands require an existing site with the same site definition as the original, making these processes impossible to execute on sites with a missing site definition.  If you find yourself in this situation I have developed this process for changing the site definition of a site back to a blank site.

NOTE: This process involves editing files that Microsoft does not support editing for, so this process is use at your own risk.  Make sure to implementing extensive testing before deleting the original content.

  1. Create a new blank site that will be used for testing. 
  2. In powershell export original site: Export-SPWeb http://site.url/ -IncludeVersions 4 -IncludeUserSecurity -path \\put\files\here -NoFileCompression (Exporting with no file compression is the key make sure to include it)
  3. Edit Manifest.xml change the Configuration attribute to 1 if it is another number. 
  4. In the Manifest.xml file change the attribute WebTemplate to "STS" 
  5. Edit Requirements.xml change the attribute WebTemplate ID to STS#1 
  6. In powershell import into the previously created blank site: Import-SPWeb https://blank.url/ -path \\put\files\here -NoFileCompression -IncludeUserSecurity 
  7. Verify test site! 
  8. Delete original site 
  9. Create new blank site with original site's url and site collection administrators
  10. Import into the just created blank site using same command and files as in step #5 
  11. Verify new site
  12. Empty recycle bins

Thursday, February 14, 2013

Refreshing Email Enabled Lists after Migration

Anytime you move your content databases to a farm using the database attach method in SharePoint 2010 (and i'm guessing SharePoint 2013) you need will need to refresh all of your email enabled lists.  The reason for this is because SharePoint stores the email enabled lists inside of the Farm Configuration Database and since the Farm Configuration database doesn't move during a database attach migration you need to refresh all of your email enabled lists back into the Farm Configuration Database.  The best way to do this is with a short script that will iterate through all sites and perform this function.  Here is the code to perform this action:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0
$sites = Get-SPSite -LIMIT all
foreach ($site in $sites) {

I found this code on this blog and he has a very good write on this issue:

I made a slight modification to the script that enables it to enurmate all sites in your farm and not just using a limited result set. 

Setting a Custom Color Palette on Chart Web Parts

The Chart Web Part is a SharePoint 2010 component that lets users generate charts from SharePoint lists or from BDC data.  This chart is great for providing simple data visualization that is embedded in SharePoint web part pages.  I had to do a project using this web part so I had to dig a little deeper into how to use the web part effectively.

The chart web part seems to just be an extension of the Microsoft .NET Chart class that allows you to specify the properties of the class via XML that is embedded in your SharePoint Web Part Page.  There are wizards and an advanced interface available on the web part pages to configure this underlying XML, but there are more options available to  you if you are willing to dig in and edit your page via SharePoint Designer.  Using SharePoint designer I was able to overcome what seems like a simple problem, how do I use a custom color palette on my chart?

I am going to outline the steps you need to take in order to add custom colors to a chart.  You can skip some of these steps and go straight to editing the XML, but I find that by completing my charts first and then editing the XML there is a lower chance of me accidentally blowing away my custom settings by going through a wizard.

  1. Add a chart web part to your page.
  2. Connect the chart to your data source using the data connection wizard. 
  3. Start the chart customization wizard to format  your chart.
  4. Select your chart type (type doesn't matter for custom palettes)
  5. On the Appearance Themes tab:
    1. Set the Theme to "Custom"
    2. Set the Transparency to "Custom"
  6. Finish the wizard setting any values other than the two above.
  7.  Launch SharePoint Designer and open the source of your page.
  8. Search for the String "PaletteCustomColors" this will take you to the embedded XML element for the custom palette.
  9. The palette is ten semicolon(;) delimited values that you can set to whatever colors you want.  For how to specify color values in this section see the paragraph below. 
  10. Save your page source and refresh the page, you should now see your custom colors!
There is a little trick to defining custom colors through this method and it will become appearant as soon as you open the file.  All colors have a four number format ex. (204, 255, 227, 130) this really threw me for a loop at first because everyone knows that colors are usually specified with three numbers in an RGB format.  It seems that Microsoft is starting to encourage the use of a four digit color specification where the extra number (the first in this case) is the transparency of the object.  Transparency is based on the percentage equal to the first number divided by 255, so 0 would be transparent and 255 would be solid.  In this situation a solid red would be 255, 255, 0, 0 and a half transparent blue would be 127, 0, 0 255.

Now that you know how to define colors you can go in and set your own palette of ten colors for use on your chart!  The chart web part will assign colors to your series based on when the values occur so the first series value will map to the first color and the next to the second, etc...

You must be careful when you use this editing XML method for changing charts because if you later use the wizards to edit your charts they may remove your customized values.  I have found that color is pretty stable and your settings will not be deleted unless you go into the wizard and change the color palette, transparency, or chart type.  But if you use this method to edit other values they may be wiped out by using the wizard.

For reference you can find the documentation for the chart class here: this documentation will show you the properties that are available on the chart class and that may be usable via the editing XML method. 

Good luck and happy charting!

Friday, February 8, 2013

Long time no post, hopefully things coming soon

Sorry for no posts in a while but work has been a little crazy over the past year and I haven't had a lot of time to focus on SharePoint and CRM.  On a good note we have now finished our upgrade from SharePoint 2007 to SharePoint 2010 successfully.  Some items have crept up lately that I think need to be documented to help others overcome the problems we have encountered.  Here is a list of things you will hopefully see from me over the next couple weeks.
  • How to successfully send out an email merge campaign from word as an email address other than the one that owns the primary outlook profile on a machine.  
  • How to create a custom color palette for use with SharePoint charts.  
  • Problems with re-provisioning the User Profile Synchronization Service
  • Refreshing email enabled lists after performing an upgrade.  
  • Possibly a post about migration from 2007 to 2010 if I think I can add more value outside of what is already documented on the internet.  
If there is anything in this list people would like to hear first let me know!