Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Thursday, May 24, 2012

Link to top level of a site collection Using SPUrl

Recently I was coding a branding package that deployed several master pages, image files and css files. The package was scoped to the site collection level, of course.

In addition to the top level site collection, there were multiple site collections located in various managed paths. I made sure my package deployed the relevant files to the root of each site collection in the Style Library and master page gallery. The next step was to make sure that the master pages were properly referencing the files in that site collection, and not in the root site collection.

A link such as shown below will not work. It will point to the Style Library at the root site collection, not necessarily to the Style Library where the feature is being installed.

<div class="interiorHeaderLogo"><a href="/"><img src="/Style Library/InteriorPageBrandingPackageAssets/images/interiorTopBar.png" border="0" style="background-position:left top"></a></div>

Many blogs correctly pointed out that I needed to use SPUrl  and reference the site collection. The problem was getting the syntax right. Most examples I found were relatively simple and were focused on simple links. I was dealing with a clickable image, which is a little more involved. Incorrect syntax will throw an error similar to:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.


Parser Error Message: Literal expressions like '<% $SPUrl:~SiteCollection/%>' are not allowed. Use  <asp:Literal runat="server"  Text="<%$SPUrl:~SiteCollection/%>" />   instead.


The proper form for the link above is:

<div class="interiorHeaderLogo">
<asp:Literal runat="server" text="<a href=&quot;/&quot;> <img src=&quot;"/>
<asp:Literal runat="server" text="<% $SPUrl:~sitecollection/Style Library/InteriorPageBrandingPackageAssets/images/interiorTopBar.png%>"></asp:Literal>
<asp:Literal runat="server" text="&quot;/&gt;&lt;/a&gt;"/>
</div>

Tuesday, January 24, 2012

Unexpected error on server associating the workflow

Recently we had to throw together a SharePoint Designer workflow in a hurry for a client. It consisted of 20 plus If Then Else statements that then triggered a separate custom task process.

About halfway through designing it, it started throwing the following error when publishing:

Unexpected error on server associating the workflow

I was able to determine that there was a default limit of 7000 on the UserDefinedWorkflowCompexity property of the web application. I used the follwoing PowerShell script to increase the limit and get passed the error:

$app = get-spwebapplication http://sharepointwebsiteurl/


$app.UserDefinedWorkflowMaximumComplexity = 30000

$app.Update()

After running this script, do an IISRESET and try publishing your workflow.






Wednesday, January 4, 2012

The Quick and Dirty Guide to Recreating the User Profile Service


It's no secret that the User Profile Service is probably the most fragile aspect of a SharePoint Server 2010 installation. It's been my experience that you either get it right the first time - or you have a difficult road ahead of you. 

It goes without saying that when implementing the User Profile Service, you should read, re read and then follow Spencer Harbar's definitive  Rational Guide to implementing SharePoint Server 2010 User Profile Synchronization

However, in my work I often encounter client installations that were done improperly or the environment itself has issues. In that case I've found that it is often quicker and easier to simply delete the User Profile Service and recreate rather than attempt to troubleshoot it. 

What follows is my quick and dirty guide to deleting and recreating it. 

When deleting and recreating the User Profile Service the following steps should be performed:

  • Stop the User Profile Synchronization Service from within Central Administration.
  • Stop the User Profile Service within Central Administration.
  • Check the Timer Jobs and make sure that the setup synchronization job is not hung. If so delete it.
  • Open the MMC and add the certificates snap in as detailed here
  • Delete all Forefront Identity management certificates you can find. They are under the Trusted Root, Trusted People and one other place. Delete them all.
  • Make sure both FIM services are disabled in the services console.
  • Create a new User Profile Service.
  • Make sure that you create a new application pool each time you create the service!
  • Make sure it is running under the farm account, and that the farm account is a member of the admin group on the server.
  • Go to 'Manage Services on Server' in Central Administration.
  • Start the User Profile Service in Central Administration.
  • Start the User Profile synchronization service in Central Administration.
  • Open the Services console and watch and see if the 2 FIM services change state. 
  • Open the certificate snap in and make sure certs have been created properly.
  • Wait a long time.
  • When the User Profile Synchronization Service shows 'started' instead of 'starting', open the services console and make sure that both FIM services show enabled and automatic.
  • Do an IIS reset.
  • See if you can now open and manage the User Profile Service. 

Wednesday, October 5, 2011

Dynamic Hyperlinks in Calculated Columns

I recently was faced with an interesting problem. I needed to create a list column that referenced a field in the list and then dynamically constructed a URL to a filtered view of a document library. Specifically, the users needed to be able to enter the title of a company in a list item, and then have clickable links created that would take them to a separate document library, and only show them documents that belonged to that company.

The solution I implemented was developed by Christophe at Path To SharePoint. His solution was a lifesaver. I give full credit to him. I did find that I had trouble following some of his instructions, so I'm going to post a simplified version of how I implemented it here, along with a few pointers that I uncovered along the way.

The solution is two fold:


  1. Create the list that will hold the name of the company and the hyperlink field
  2. Embed a Content Editor web part in the page that contains a JavaScript that will render the hyperlinks in a friendly manner.

Creating the list:

For illustration purposes, we'll have a list that holds the titles of websites and builds links to their websites dynamically. 

Create a list with a field called "Title". This will hold the name of the website. Next create a field called "Hyperlink". This field will be a calculated field that will dynamically build the hyperlink to the website of that name. 

Enter the following formula in the definition of the Hyperlink field: 


This will  dynamically build a hyperlink of http://www.[Title].com. It will also open the link in a new window. However there's a problem. I created a list item and entered "ESPN" as the website title. Here's what it looks like:



As you can see, the hyperlink isn't exactly user friendly, and it also isn't a clickable link. There is no way I know of to make a dynamically built hyperlink in a calculated field that is user friendly and clickable. Christophe came to the rescue by pointing out that you could embed a content editor web part at the bottom of a page that holds a script that will render the hyperlink correctly.

So, create a web part page, place a list view at the top of the page and place a CEWP at the bottom of the page. You can grab his script at using calculated columns to write html. Make sure that the CEWP is at the bottom of the page. Also, make sure you set the Chrome to 'None' so that the CEWP is completely invisible to the users.

Now when you view your page, it will look like this:



You can see the link now renders correctly, and it is also clickable. Since the hyperlink is a calculated field, you can edit the list item and change the title from ESPN to MSDN. The hyperlink will automatically update.

This is a powerful tool. I was able to use it to link to a filtered view of other document libraries so that only documents belonging to the item in question were displayed.

Thanks to Christophe for the great work.


Friday, February 4, 2011

SharePoint 2010 Alternate Access Mapping

I recently got tripped up while setting up Alternate Access Mappings on a test server I was using for development.

I built a Share Point Foundation farm using the default as the default URL. I needed to mimic a client environment to use "TheHub" as the default URL for demonstration purposes.

I followed the step by step instructions found on TechNet for accomplishing this, (Located Here), but I was still unable to browse my site.

Here are the high level steps for accomplishing this task:

  1. The first step is to disable the loop back check on the server. In my case, this was a test server, so I was doing development and browsing the site from the server itself. Until you disable the loopback check, you will not be able to hit the site successfully with the new URL. I used method 2 located here.
  2. Next, Open Central Administration /Application Management/Configure Alternate Access Mappings and create a new internal URL as described here.
  3. The next step, and the one I neglected, is to open the hosts file located at C:\Windows\System32\drivers\etc and add an entry for 127.0.0.1 and point it to the new URL. You'll need to open Notepad with 'Run As Administrator' permission in order to do this. For more information on editing the host file, check out this article: Creating Entries in the Hosts File.
  4. The final step is to go back into Central Administration /Application Management/Configure Alternate Access Mappings  and select "Edit Public URLs" from the menu, and swith the entries so that the new URL is in the default text box and the servername entry is in the intranet text box and click Save.
This will insure that SharePoint uses the new URL as the default URL; otherwise alerts and other emails will go out using the servername instead of the desired URL.

Monday, November 29, 2010

Splitting Sites Into New Site Collections

Part of the my current migration effort consists of taking our existing 2007 farm and upgrading it to SharePoint 2010. Given that our current SharePoint 2007 farm consists of a single site collection and content database, one of my objectives is to split out some content into it's own site collection and corresponding content database.

Here, at a high level, is how I did that.The process is farily simple and straightforward:

  1. Export the selected content to a directory on the local file system using the stsadm -o export command.
  2. Rename the existing web that was just exported using stsadm -o renameweb.
    1. I renamed mine by appending _OLD" the the web name.
    2. This will ease deleting content later.
  3. Create a managed path in Central Administration to reflect the desired managed path for the new site collection.
  4. Create the new content database in Central Administration.
  5. Temporarily set the pre existing content database to "Offline" in Central Administration.
    1. This will force the new site you are about to create to be created in the new content database.
  6. Create a new top level site at the desired url, using the newly created managed path using stsadm createsite.
    1. Since this is the top level site for your new site collection, you'll need to include the -owneremail and -ownerlogin flags in the command.
  7. Import the content of the directory on the local filesystem into the newly created web using stsadm -o import.
  8. Delete the original web and subwebs using stsadm -o deleteweb.
  9. Open Central Administration and set all content databases to 'Ready'.
  10. All new subwebs created under the new site collection will be placed in the new content database. Any new subwebs created in the original site collection will be placed in the original content database.
At this point you should be able to navigate to and successfully view the content you have split off into it's own site collection. Another check is to examine the size of the newly created content database in SQL Server. It should now reflect the size of the data that was imported into it.

One final step is to make sure that the "Manage Content and Structure" option is visible under Site Actions on your new top level site . If it is not listed, you'll need select Site Settings at the new top level site and activate the following features:

  • Site Collection Features: SharePoint Server Publishing Infrastructure
  • Site Features: SharePoint Server Publishing
Once these features are activated, "Manage Site Content and Structure" will now be listed under Site Actions on the top level site of the new site collection.

Friday, October 29, 2010

An unhandled exception occurred in the Silverlight Application

I was getting "An unhandled exception occurred in the Silverlight Application" when I tried to create a new site in my new SharePoint 2010 farm. I was unable to create even the most basic blank site.

Thanks to Simon Carpentier at SharePoint Overflow, I was able to resolve this issue.



To resolve the issue, you need to go to Central Administration/Application management/(Select the web application)/General Settings/Set Web page Security Validation to "On"

Thursday, October 21, 2010

$Resources:DataSourceContentTypeName Error

After upgrading my SharePoint 2007 farm to 2010, when attempting to create  new site using a custom site template I received the error: "The content type name '$Resources:DataSourceContentTypeName;' cannot contain: " as shown below.


After many hours spent attempting to decipher log file entries, Googling, and researching, I zeroed in on the fact that I had a Reporting Services content type that seemed to have been corrupted in the upgrade process.

In 2010, the content type displayed as:


In 2007, the content type displayed correctly:


What was happening is that when I attempted to create the new site with the custom template, it was attempting to activate the corrupt content type. The solution to this issue is to simply delete and recreate the corrupt content type; but this is easier said than done.

Here is the process I used to resolve the issue.

Before a Content Type can be deleted, you must first remove it from every place it is being used. I found the easiest way to identify content type usage is to use the excellent tool SharePoint 2010 manager. This is a truly excellent tool. I was able to identify every place the offending content type was used quickly and easily, and remove it.

Once the content type was no longer being used, I was still unable to delete the content type. I would receive an error stating that the content type was "part of a feature" and could not be deleted.

The next step was to uninstall the feature, which I determined to be the "ReportServer" feature. Here's where it gets tricky. You must do things in the correct order to resolve the issue. The steps, and the order to perform them are:

  • stsadm.exe -o deactivatefeature 
  • stsadm.exe -o uninstallfeature -force 
  • stsadm.exe -o execadmsvcjobs 
  • stsadm.exe -o installfeature
  • stsadm.exe -o activatefeature
This will properly deactivate, uninstall, reinstall and activate the feature. Once this process is complete, your content types should display correctly, and not as $Resources:........

At this point you've cleaned up the corrupt content type. However, you still cannot create a new site with your custom template because the previously created template still references the old corrupt content types. You need to now create a new site template. The new template will be clean, and there will be no trace of the corrupt content types.

You can now create a site with the template.

Friday, October 1, 2010

Configuring The Unattended Service Account in SP 2010

In the process of configuring Excel Services on my test farm, I ran into an issue with enabling data refresh on Excel spreadsheets. I could get the spreadsheet to display in SharePoint, but I couldn't refresh the data.

I traced the issue to the fact that the unattended service account wasn't working properly. Further digging led me to the fact that my Target Application in the Secure Store Service application wasn't configured correctly.

Here are the steps I took to create a properly configured Target Application, and use that to configure the Unattended Service Account in Excel Services.

The first step is to create a valid Target Application in the Secure Store Service application:

Go to Cenral Administration > Manage Service Applications > Secure Store Service.

Provision the Target Application by giving it a Target Application ID, Display name, etc as shown below. It is important to select "Group" as the target application type, not individual which is the default.


Click Next and accept the defaults on the second screen. Click Next and specify the Target Application administror(s) and desired. The next box is very important. The only way I was able to get data refresh to work was to set the SharePoint Farm Account as the members. Simply enter the name of the farm admin account in the members box and validate it.

Click OK and create the Target Application. Once it's been created, you need to set the credentials for the account, so it can be encryped into the Secure Store database.

To set the credentials, select the dropdown on target Applicaton you just created and choose "Set Credentials". Enter the name of the farm account you entered as 'members', and enter the password.


At this point you've successfully created and provisioned the Target Application. The final step is to set the unattended execution account in Excel Services.

To do this, go to Central Administration > Manage Service Applications > Excel Services > Global Settings.

Scroll to the bottom of the settings page a type in the Target Application ID of the Target Application we just created. Click OK.

Once I completed these steps, I was finally able to get my Excel spreadsheets to properly refresh in Excel Services.

Thursday, September 30, 2010

No Excel Calculation Services is available in the farm

In the course of building my new SharePoint 2010 farm, when attempting to view an Excel Spreadsheet in the browser, I received the error below:


Not exactly helpful.

I dug into the log files and found an error that stated "No Excel Calculation Services is available in the farm". The next step was to figure out where this service was located and why it was not available.

A bit of digging in Central Administration led to Central Administration > Services on Server. Once there it was obvious what the problem was. The Excel Calculation Service was stopped.



I started the service and attempted to open the original spreadsheet. This time, I got a different error message, indicating that the operation could not be completed, and asking me to wait a few minutes and try again.



While I waited, I recycled the application pool and restarted the browser. This time, my spreadsheet loaded as expected. Problem solved.

Friday, September 10, 2010

SharePoint 2010 List View Differences

In the course of upgrading my farm from 2007 to 2010, one of the differences I've encountered is in the List View webpart.

In my 2007 farm, I have several List Views that are filtered by user. Basically they are designed to show only 360 Reviews by others of myself; whereas the list contains all employee reviews.

This is what it looks like in SharePoint 2007:









After upgrading to 2010, this is what it looked like:














After doing a little digging, I determined that this error was caused by the Ajax settings in the new list view. I edited the webpart and enabled the two settings below:

























At this point, the List View displayed the data properly, but the style was different:









I checked the Style settings by editing the current list view, and I verified that the webpart was set to use the "Document Details" on both the 2007 farm and the 2010 farm. Evidently, the "Document Details" style behaves differently in 2010 than it does in 2007. I also made sure the default setting of "collapsed" was selected.

A little experimentation showed that if I set the list view to use the "Default" style, the webpart displayed  as I wanted, as shown below:




Tuesday, September 7, 2010

SharePoint 2010 Page Viewer Web Part Forcing Download of .htm Files

I recently ran across an issue after upgrading from SharePoint 2007 to SharePoint 2010 where a page that contained a Page Viewer Web Part that displayed a .htm file. Every time the page was rendered, the user was prompted to download and save the file. The page would not display properly, and the site would hang.

I found the answer at Impossible as Possible. This solution saved me hours of digging.

SharePoint 2010 has an enhanced security model. One aspect of this is that the setting for browser file handling is set to strict by default. As explained by Microsoft here, this is by design to prevent malicious scripts from exploiting security.

To resolve the issue simply open Central Administration\Application Management\Manage Web Applications. Scroll down until you see "Browser File handling". Change it from Strict to Permissive as shown below.




You can now view html files in the iFrame as desired.

Identifying Problematic Features After Upgrade

In the course of upgrading my SharePoint 2007 farm, one of the more frustrating experiences was identifying problematic features or items that failed to upgrade properly.

One of the issues I recently dealt with was an error produced when I selected "Site Actions", then "Manage Content and Structure". This would immediately produce an error with a cryptic correlationID message. Searching the internet produced a consensus that I had a corrupt list on the site. Here is how I tracked it down and eliminated it.

The first step was to edit the web.config file to produce a more usable error message. In the web.config, alter it so that "customErrors mode = off", and CallStack = True". Do an IIS Reset and you should now get a more usable error message.

In my case the call stack indicated that the error was because List Template ID 432 was not installed. So, I knew this was a corrupt list, and it was a list on the main page of my site. A quick Google search turned up the fact that that List Template 432 was the KPI List template, which was deprecated in SharePoint 2010. Any list in my production farm built using this template would have to be deleted.

Now that I knew what type of list it was, I went back to my production 2007 farm to identify the lists in my farm built on this template. I used ControlPoint to run a report that identified every site in my farm that had one of these lists on it.

Using this information, I set about deleting the corrupt content on my 2010 farm. Some people have indicated that you can use SharePoint Designer 2010 to connect to the site and delete the content. I was unable to do this, as SharePoint Designer would not display content for pages that contained the corrupt list.

I finally resorted to using stsadm -o forcedeletelist -url to get rid of the lists. Once I deleted the offending content, I was able to open the Manage Content and Structure page and browse site content normally.

One last tip. Once you get Manage Content and Structure working, you can simply click through every site in your Site Collection. If a site contains any corrupt items, it will produce an error rather than expanding the treeview. This is a fast way to check sites for corrupt content.

Wednesday, August 25, 2010

SharePoint 2010 Upgrade Failure - Executing DDL Script

I'm in the process of upgrading our SharePoint 2007 farm to 2010, using the DBAttach method. I created a Server 2008R2 VM, installed SharePoint 2010 and configured the farm with default settings.

I backed up our existing content database and restored it to the new server. Our content database is approximately 150 GB, so it's quite large. I ran Test-SPContentDatabase. This reported some missing features, but indicated that none would cause the upgrade to fail. Since this is a test environment, I decided to go ahead and upgrade the database.

I then executed Mount-SPContentDatabase to upgrade and attach the content database. The process reached 19.69% after an hour and appeared to hang. I was able to log into Central Admin and monitor the process as designed. After several hours of what appeared to be no activity, I ran Sp_Who2 in SQL Management Studio and found that I had two Spids listed as SUSPENDED. One was an INSERT and one was a SELECT. One was blocking the other. SQL was deadlocked. After 13 hours, the upgrade failed.

Reviewing the upgrade log files indicated several issues:

  1. The first issue I noticed is that the issues identified by Test-SPContentDatabase (missing features) as not being fatal errors were listed in the log file as "The missing feature may cause upgrade to fail. Please install any solution which contains the feature and restart upgrade if necessary." It would appear that there is disagreement between Test-SPContentDatabase and the actual upgrade process.
  2. Secondly, and more importantly, it appears that while executing step 84 of 128, a fatal exception occurred. The following entry was recorded:
Action 4.0.98.0 of Microsoft.SharePoint.Upgrade.SPContentDatabaseSequence failed.


[STSADM] [SPContentDatabaseSequence] [ERROR] [8/25/2010 3:50:59 AM]: Exception: Could not allocate space for object 'dbo.AllDocStreams' in database 'MOSS_WSS_Portal_Content' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.
Autogrow on the SQL log file was set to 10% and had a max file growth limit.  When the upgrade process began populating the AllDocStreams Content Column, two things happened:

  1. The larger the transaction log got, the longer it began taking to autogrow. Once the autogrow process approached two minutes, errors began.
  2. Next, the transaction log grew so large that my partition ran out of disk space. 
I believe this is happening because none of the transactions are being committed during the upgrade process; thus allowing a rollback in case of failure. Paradoxically, this very failsafe is actually causing it to fail in my case.

I started with a 140 GB content database and it completely filled my 300 GB partition. When performing the upgrade, you need to plan on having plenty of drive space available. Once I moved the database to a terrabyte partition, the error was resolved. I found that, in order to reliably upgrade a SharePoint 2007 content databases to 2010, you'll need to plan for allowing the content database to triple in size during the upgrade. If your content database is 100 GB, you'll need at least 300 GB for the log files to grow.