Thanks!

Cascading Drop Down Sharepoint Foundation 2010

After the release of Sharepoint 2010, the request for Cascading Drop Down, filtered drop down, dependent drop down or what you call them is not so common anymore. The reason for this is of course the Managed Metadata Service, which is included in Sharepoint Server 2010.

There are still times, however, when you’d want to use the functionality below to filter your drop downs. If you for instance are running Sharepoint Foundation, not Server, you won’t have the Managed Metadata Service available at all. Or perhaps you are running server, but you want to use list data and not terms from the term store.

Read more about Cascading Drop Down in my previous post for Sharepoint 2007.

The solution
The solution below is tested with Sharepoint 2010, and is basically the same procedure as the one for 2007. The list is still standard Sharepoint, which gives great flexibility and stability. This way, the filtering is done in the forms for creating and editing elements. Because of this, you don’t even have access to the server to implement this.

1. Add the Jacascript
Download the Jquery file jquery-1.6.2.min.js by Jquery.com. Download jquery.SPServices-0.6.2.zip from the Jquery Library for Sharepoint Codeplex site (newer version is probably also OK). Upload jquery-1.6.2.min.js and jquery.SPServices-0.6.2.min.js (from the zip file) to a document library that everyone accessing your site has access to (a library on the top level site can be wise).

2. Create your relationship lists
Make two lists, one for the parent (Country) and one for the child (City):

Countries list:

Cities list:

The Country column can be a look up from the Countries list, but you can just as well use a standard single line of  text column, which I have done here. This can theoretically give better performance, but you must of course be precise when filling out the County column so that the values here matches the ones in the Countries list.

3. Create the list that is actually using the Drop Down

Vacation Plans list:

This is the list where I want my Cascading Drop Downs. Country and City are lookup columns against Countries and Cities lists. The lookups goes against the title field in the respective columns.

4. Make the magic happen
In Sharepoint Designer, create your own NewForm.aspx (or EditForm.aspx, you’ll need both if you want it to work when editing items). Editing forms is a lot easier now with Designer 2010.

Just below
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

insert this code:

<script language="javascript" type="text/javascript" src="/address to document library/jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/address to document library/jquery.SPServices-0.0.6.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Cities",
   relationshipListParentColumn: "Country",
   relationshipListChildColumn: "Title",
   parentColumn: "Country",
   childColumn: "City",
   debug: true
  });

 });
</script>

Save and create a new item using your new form:


Voila!

5.Explained:
relationshipList: “Cities” : this is the name of the relationship list = the list containing parent and child
relationshipListParentColumn: “Country” : Column name from the Cities list
relationshipListChildColumn: “Title” : Column name from the Cities list
parentColumn: “Country”: Column name from the list where the drop down is = Vacation Plans
childColumn: “City”: Column name from the list where the drop down is = Vacation Plans

You have lost of other options explained at the project site on Codeplex like sorting, multiple levels and so on.

Thanks to Marc D. Anderson for making this available.

I tested this on Sharepoint Server Enterprise 2010 with Service Pack 1 installed. It should work just as fine on Sharepoint Foundation. My installation is English Sharepoint with Norwegian Language Pack, but pure English should be jsut as fine.

KDC_ERR_S_PRINCIPAL_UNKNOWN

I got this error in the event log on a fresh Sharepoint Server 2010 February Cumulative Update installation:

A Kerberos Error Message was received:
 on logon session
 Client Time:
 Server Time: 17:6:26.0000 4/2/2011 Z
 Error Code: 0x7 KDC_ERR_S_PRINCIPAL_UNKNOWN
 Extended Error: 0xc0000035 KLIN(0)
 Client Realm:
 Client Name:
 Server Realm: DOMAIN.LOCAL
 Server Name: MSSQLSvc/sqlserver.domain.local:1433
 Target Name: MSSQLSvc/sqlserver.domain.local:1433@DOMAIN.LOCAL
 Error Text:
 File: 9
 Line: f09
 Error Data is in record data.

Solution:

Continue reading →

Content Query Web Part – image on left with formatted date and description

There are tons of blog posts about using the Content Query Web Part to show for example news from an Announcement list. I myself learned a lot from this Heather Solomon post a couple of years ago.

In this post I am going to show you step by step how to create an Item Style for your CQWP that displays an announcements image, title, date and the first 250 characters of the description. This works for Sharepoint Server 2010, and unlike 2007 you don’t have to export the CQWP and change the code – no notepad this time!

 

1. For best practise, I created my own Content Type inheriting from the Announcement Content Type. Lets call this CompanyAnnoucement. To CompanyAnnoucement I added an existing site colum: Rollup Image. Add CompanyAnnoucement to the list(s) you want. If lots of people needs direction on this step, I’ll make a blog post about it.

Continue reading →

Error installing Cumulative Updates

I was installing the latest Cumultative Updates (December 2010 version) on a small Sharepoint Server 2010 farm. I installed both the Foundation and Server hotfix package on the application server and then the web front end.

Next step was running the Sharepoint 2010 Products Configuration Wizard on the application server. The wizard started out just fine, but I only got to step 9 (“The farm is being upgraded in the timer service process. The task is 10.00% completed.”) where it subsequently failed (Configuration failed).  The error message was:

An exception of type Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException was thrown.  Additional exception information: Failed to upgrade SharePoint Products.”

Reading in the logs revealed what seemed to be why the upgrade failed, but no hint on how to fix it:

01/04/2011 15:27:39  14  INF                    Resource id to be retrieved is UpgradeTaskFailConfigSyncDisplayLabel for language English (United States)
01/04/2011 15:27:39  14  INF                    Resource retrieved id UpgradeTaskFailConfigSyncDisplayLabel is Failed to upgrade SharePoint Products.
01/04/2011 15:27:39  14  INF                  Leaving function StringResourceManager.GetResourceString
01/04/2011 15:27:39  14  INF                  Entering function Common.BuildExceptionMessage
01/04/2011 15:27:39  14  INF                    Entering function StringResourceManager.GetResourceString
01/04/2011 15:27:39  14  INF                      Resource id to be retrieved is ExceptionInfo for language English (United States)
01/04/2011 15:27:39  14  INF                      Resource retrieved id ExceptionInfo is An exception of type {0} was thrown.  Additional exception information: {1}

When I ran the Configuration Wizard again on the application server, it succeded, but I suspected the upgrade was not completed. I subsequently ran the Wizard on the WFE also, where the upgrade succeded. In Central Administration, I now had one “Succeded” Upgrade Session on the WFE and one “Failed” Upgrade Session” for the application server on the Upgrade Status Page in Central Administration.

Restarting the servers or running the Configuration Wizard either via different psconfig variations or UI did not give me a successful upgrade session for the application server.

The next day I also got a warning in the Health Analyzer:

Product / patch installation or server upgrade required.
All required products must be installed on all servers in the farm, and all products should have the same patching and upgrade level across the farm.
Upgrade is required on server APPSERVER. Without the upgrade, the server is not in a supported state.

Obviously not a perfect situation. The solution which solved the problem and completed the upgrade was also mentioned. Here is the Powershell command that did the trick for me:

PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

Sharepoint 2010 December Cumulative Updates

The December 2010 Cumulative Updates for Sharepoint Foundation and Sharepoint Server 2010 has been released. They seem to contain quite a few fixes, especially for the User Profile Service which from what I read will synchronize faster (It might actually look like this is the case, I think User Profile Synchronization was somewhat faster now). For some reason they are not published on the official Sharepoint Update page, which is why I am writing this post.

I have installed the updates in a 2-server farm, everything seems to work fine afterwards.

Unlike after the October Updates, I didn’t have to re-provision the User Profile Synchronization Service afterwards, as this service was listed as started when I had finished upgrading. (If re-starting/re-provisioning this service, remember to add the Farm Account to Local Administrators and reboot before starting the service).

I have linked to the downloads on my download page.

Version number after updating should be 14.0.0.5130.

Update: The December 2010 Updates are as of 07.01.2011 now available via the Sharepoint 2010 Update Resource Center.

FeatureUpgrading not firing in Sharepoint 2010 Sandbox

So,

you create a sandboxed solution in in Visual Studio 2010 for Sharepoint 2010, and you use a feature receiver to handle upgrades. You add a CustomUpgradeAction to your feature.xml file to fire some code when feature is upgraded.

You forget that you cannot simply write to the event log or the Sharepoint (ULS) logs in a sandboxed solution, and add some code like this:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
        System.Diagnostics.EventLog.WriteEntry("My Company, solution x", ex.Message);
});

in the FeatureUpgrade method to write something to the event log, maybe to check what went wrong if you have some errors in your code.

You will see that the FeatureUpgrade method is not firing when upgrading. You won’t get any errors either, and attaching to the SPUCWorkerProcess.exe for debugging won’t help either – nothing happens.

To make things work, you have to remove the statement writing to the log, this prevents the event receiver to function properly.

P.S. If you add a statement like the one above to the FeatureActivated method, you will at least get an error message so you know what’s happening.