Thursday, 6 January 2011

Error Creating User Profile Connection - Unable to process Create Message

I have managed to setup User Profile Synchronisation in a few different environments without any problem - Connection created, FIM services are running, user profiles are imported successfully. 

Recently I was trying to setup a new server farm in the production environment.  I followed the exact same procedure as I always do, but this time I am getting a new error message when I tried to create a new User Profile Connection - Unable to process Create Message:


And I was getting these errors in the error log:


Microsoft.ResourceManagement.Service: System.InvalidOperationException: Retrieve schema failed
   at Microsoft.ResourceManagement.ActionProcessor.SyncConfigActionProcessor.Create(String typeName, IList`1 createParameters, Guid creator, Guid cause)
   at Microsoft.ResourceManagement.ActionProcessor.SyncConfigActionProcessor.ProcessInputRequest(RequestType request)
   at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.ProcessInputRequest(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction(RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request, Guid requestIdentifier, Object redispatchSingleInstanceKey)
   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request)
   at Microsoft.ResourceManagement.WebServices.ResourceManagementService.Create(Message request)

This is weird because I followed the exactly same procedure as the other environments.  FIM services are running, service accounts are setup properly, Net Bios Name flag enabled for the UPS, what was going wrong? Someone got the same error as me here and they fixed the problem by pointing the Sync to a Windows 2008 Domain Controller:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/6c68c067-5b2a-482f-925b-5a0a25759344

However I have confirmed both the domain controller of production environment and other environments Windows 2003.  So what was wrong?  I spent 2 overnights, and one premium support called was raised and I was still going no where, where I was 4 days away from the production launch. 

I didn't install the August cumulative updates due to an error I posted earlier (link).  Then I thought....well, worth a try as I have tried out every thing already.  And you know what? That fixed the problem! And this also fixed the August CU problem that I had earlier (it broke the User Profile Service Application). 

So if you are getting this error when you create an user profile synchronisation connection, here are the two things that you should do:
  1. Check your domain controller
  2. Install the August (or later) Cumulative Updates

SharePoint 2010 August Cumulative Updates breaks ForeFront Identity Manager

I have recently came across a bug in the Newsfeed Settings. I have gone into my newsfeed setting and unchecked some of the activity types. The first time I done it, it was fine. However when I try to do it again, I noticed that my changes doesn't get saved.

Found nothing out there, so I decided to apply to SharePoint 2010 August Cumulative Updates:
SharePoint Foundation 2010: kb2266423
SharePoint Server 2010: kb2352342

After I applied the updates, my problems gone! I can now save my newsfeed settings.

BUT!!!! (You know that I am going to say this, right?) It produces another problem.

As usual, after the reboot required by the updates, my two ForeFront Identity Manager services have stopped. The Forefront Identity Manager Service has started successfully, but I couldn't get the Synchronization Service start.

I am getting the following error:


And when I checked my error log, I am getting a WorkflowManagerException: Forefront Identity Management Service does not support workflows of type 'Microsoft.ResourceManagement.Workflow.Activities.SequentialWorkflow, Microsoft.ResourceManagement, Version=2.0.2450.5" error:


To fix this problem, simply delete your User Profile Service Application, and recreate a new one.  Somehow the cumulative update does not work with the service application that was created using the old binary?

Fixing SharePoint 2010 Lookup Drop Down 20 Items Limit

As you might have noticed already, SharePoint (both 2007 and 2010) will render your lookup drop down column differently depends on the number of item in the drop down list. If you have less than 20 items, SharePoint will just render the drop down using the normal drop down list control.

However SharePoint will change the rendering style when there is more than 20 items. Instead of the simple drop down list control, it will be changed to a textbox + ajax + filtering list, like the following:



So when you start typing in the textbox, it filters the options, allows the user to select an item from a large list. There are pros, and of course there are cons:
- If you decide to select from the list, you need to do a double click in order to pick an option
- The free-text box gives an impression that you can free-text, which ends up saving empty string
- Inconsistent user experience if you have other drop down list in the form that has less than 20 items.
- There are some rendering issue for the Ajax Drop Down list in SharePoint 2010

To get around this, I have implemented a JQuery solution. Basically the script does the following if the drop down has more than 20 items:
- Hide the text box
- Hide the drop down arrow
- Provision the options in a simple drop down list, register an OnChange event to set the lookup hidden field that SharePoint is using.
- Add the drop down to the page.

Insert the following script to the New/Edit form (by using a content editor web part or custom ribbon javascript). I am assuming that you have a reference to the JQuery library in your master page.

Code Snippet
  1. <script>
  2. $(document).ready(function () {

  3. // Name of the column (Display Name)
  4. var columnName = "Lookup";

  5. // Override the Drop Down List
  6. OverrideDropDownList(columnName);

  7. // Main Function
  8. function OverrideDropDownList(columnName) {

  9. // Construct a drop down list object
  10. var lookupDDL = new DropDownList(columnName);

  11. // Do this only in complex mode...
  12. if (lookupDDL.Type == "C") {

  13. // Hide the text box and drop down arrow
  14. lookupDDL.Obj.css('display', 'none');
  15. lookupDDL.Obj.next("img").css('display', 'none');

  16. // Construct the simple drop down field with change trigger
  17. var tempDDLName = "tempDDLName_" + columnName;
  18. if (lookupDDL.Obj.parent().find("select[ID='" + tempDDLName + "']").length == 0) {
  19. lookupDDL.Obj.parent().append("<select name='" + tempDDLName + "' id='" + tempDDLName + "' title='" + tempDDLName + "'></select>");

  20. lookupDDL.Obj.parent().find("select[ID='" + tempDDLName + "']").bind("change", function () {
  21. updateOriginalField(columnName, tempDDLName);
  22. });
  23. }

  24. // Get all the options
  25. var splittedChoices = lookupDDL.Obj.attr('choices').split("|");

  26. // get selected value
  27. var hiddenVal = $('input[name=' + lookupDDL.Obj.attr("optHid") + ']').val()
  28. if (hiddenVal == "0") {
  29. hiddenVal = lookupDDL.Obj.attr("value")
  30. }

  31. // Replacing the drop down object with the simple drop down list
  32. lookupDDL = new DropDownList(tempDDLName);

  33. // Populate the drop down list
  34. for (var i = 0; i < splittedChoices.length; i++) {
  35. var optionVal = splittedChoices[i];
  36. i++;
  37. var optionId = splittedChoices[i];

  38. var selected = (optionId == hiddenVal) ? " selected='selected'" : "";
  39. lookupDDL.Obj.append("<option" + selected + " value='" + optionId + "'>" + optionVal + "</option>");
  40. }
  41. }
  42. }

  43. // method to update the original and hidden field.
  44. function updateOriginalField(child, temp) {
  45. var childSelect = new DropDownList(child);
  46. var tempSelect = new DropDownList(temp);

  47. // Set the text box
  48. childSelect.Obj.attr("value", tempSelect.Obj.find("option:selected").val());

  49. // Get Hidden ID
  50. var hiddenId = childSelect.Obj.attr("optHid");

  51. // Update the hidden variable
  52. $('input[name=' + hiddenId + ']').val(tempSelect.Obj.find("option:selected").val());
  53. }

  54. // just to construct a drop down box object. Idea token from SPServces
  55. function DropDownList(colName) {
  56. // Simple - when they are less than 20 items
  57. if ((this.Obj = $("select[Title='" + colName + "']")).html() != null) {
  58. this.Type = "S";
  59. // Compound - when they are more than 20 items
  60. } else if ((this.Obj = $("input[Title='" + colName + "']")).html() != null) {
  61. this.Type = "C";
  62. // Multi-select: This will find the multi-select column control on English and most other languages sites where the Title looks like 'Column Name possible values'
  63. } else if ((this.Obj = $("select[ID$='SelectCandidate'][Title^='" + colName + " ']")).html() != null) {
  64. this.Type = "M";
  65. // Multi-select: This will find the multi-select column control on a Russian site (and perhaps others) where the Title looks like 'Выбранных значений: Column Name'
  66. } else if ((this.Obj = $("select[ID$='SelectCandidate'][Title$=': " + colName + "']")).html() != null) {
  67. this.Type = "M";
  68. } else
  69. this.Type = null;
  70. } // End of function dropdownCtl
  71. });
  72. </script>
The script will then turn the complex drop down list (if it has more than 20 items) to the simple drop down list:



Originally I extended the SPServices JQuery Library to fix the drop down issue. So you may find that my scripts contains little portion of the library. I have integrated the above solution with the Cascading Drop Down list function provided by the SPServices library. Let me know if you want to obtain the extended script.
Update:
Since there are request for the Extended SPServices, I have make it available for download. You can download it from here. (Please rename the extension from .txt to .js)
Few notes before you use this:

1. This extended version is based of SPServices version 0.5.7

2. I have extended SPCascadeDropDowns and called the new function SPCascadeDropDownsEx

3. The original SPServices expects you to have the parent-child list in the following format:
Parent1 - Child1a
Parent1 - Child1b
Parent1 - Child1c
Parent2 - Child2a
Parent3 - Child3a
Parent3 - Child3b

However I have changed this so that it works with a child list and a parent list. For example, I have a child list with list item Child1a, Child1b, Child1c, Child2a, Child3a, Child3b. And then I create a parent list with a multi-valued lookup child colume like this:

Parent1 - Child1a, Child1b, Child1c
Parent2 - Child2a
Parent3 - Child3a, Child3b

(Sorry for the rough explanation, I will include screenshots when I have the system around)

And this is how I invoked the function:
// Enable Cascading Drop down for Department
$().SPServices.SPCascadeDropdownsEx({
relationshipList: "Department",
relationshipListParentColumn: "Title",
relationshipListChildColumn: "AreaOfImpact",
parentColumn: "Department",
childColumn: "Area Of Impact",
relationshipListType: "LookupMultiValue",
promptText: "--- Please select ---",
debug: false
});
So in the above script:
- relationshipList is the parent list
- relationshipListParentColumn is the name of the parent column in the parent list
- relationshipListChildColumn is the name of the childLookup column in the parent list
- parentColumn is the display name of the parent drop down list
- childColumn is the display name of the child drop down list
- relationshipListType is the type of the relationshipListChildColumn in the parent list

Thursday, 28 October 2010

Disable MySite and Tagging in SharePoint 2010

SharePoint 2010 provides some cool social features like social tag, note board, and ratings which nicely integrated with MySite. However there might be chance that you don’t want to roll out these features, due to various reasons like change management, training, and governance.

You can disable these features in your server farm and enable them when you are ready. Here are the instructions to disable the features.

  1. Logon to Central Administration web site, go to the Application Management section, and click Manage service applications.
  2. Click the user profile service application item in your farm (by default, it is “User Profile Service Application”)
  3. Click “Manage User Permissions” under People.
  4. In the “Permissions for User Profile Service Application” pop up, select a user group, e.g. All authenticated Users.
  5. Uncheck the “Permissions” item, base on what you want to disable. For your information
    • Use Personal Features – My Links, My Colleagues, Personalization.
    • Create Personal Site – My Site
    • Use Social Features – Tagging, Note Board, and Ratings
  6. Click OK to save the settings.

ManageUserPermissions

Please note, unselect Social Features does not remove the “Tags and Notes” group from the ribbon. It will still show up on the page but it will grey out.

Grey_Out_Tags_and_Notes

To hide the “Tags and Notes” from your site, there’s actually a farm feature that you need to disable. To disable this feature:

  1. Logon to Central Administration web site, go to the System Settings section, and click Manage farm features.
  2. There is a feature called “Social Tags and Note Board Ribbon Controls”. Deactivate it to hide the “Tags and Notes” group from the ribbon.
  3. Now go to your site and the “Tags and Notes” should be removed from the Ribbon.

SocialTagsFeature

Tuesday, 26 October 2010

Creating Term Set in SharePoint 2010 Programmatically

Managed Metadata is a very nice feature introduced in SharePoint 2010. It allows you to define terms in a hierarchical collection centrally, and create a managed metadata field that is reference a term sets.

By using the Term Store Management Tool found in Managed Metadata Service, you can create a term set either manually, or by importing a CSV file. You can also create a term set programmatically, either by a feature receiver or a console application. You may ask “Why do I want to provision a term set programmatically?”. Well, by creating the term set programmatically, you are able to define a fixed ID/GUID for you term set or term, and this becomes handy if you want to provision a managed metadata field in a feature (Angus has created an excellent article on how to do this).

First, you will need to add a reference to “Microsoft.SharePoint.Taxonomy.dll”, which should not be too hard to find in Visual Studio 2010. Next, an obviously, you will need to put the following line:

Code Snippet
  1. using Microsoft.SharePoint.Taxonomy;

And here is the code:

Code Snippet
  1. string siteUrl = "http://sharepoint2010";
  2. Guid newTermSetId = new Guid("{60F494A0-C31C-4D7C-9C9B-D8AF3191F3D5}");
  3. Guid newTermId = new Guid("{E39C3477-500E-4EB0-9891-0785F840DF53}");
  4. using (SPSite site = new SPSite(siteUrl))
  5. {
  6. TaxonomySession session = new TaxonomySession(site);
  7. if (session.TermStores.Count > 0)
  8. {
  9. // Get a reference to the store
  10. TermStore store = session.TermStores["Managed Metadata Service"];
  11. // Create a group
  12. Group group = store.CreateGroup("SharePointEgg.Test");
  13. // Create a term set in the group, with a pre-defined ID
  14. TermSet termSet = group.CreateTermSet("Term Set Test", newTermSetId, 1033);
  15. // Create a term in the term set in the newly created term set, with a pre-defined ID
  16. Term term = termSet.CreateTerm("Term 01", 1033, newTermId);
  17. // Save everything by calling CommitAll
  18. store.CommitAll();
  19. }
  20. }

And here is the end result:

Wednesday, 3 February 2010

Remove button from the Ribbon in SharePoint 2010

In SharePoint 2007, I have quite a few requests from different client to remove button from the document list view, such as the “Edit in Datasheet” and “Open with Windows Explorer” button. I was able to solve the problem by writing a Javascript to hide the button.

Ribbon is introduced in SharePoint 2010. We can easily make customization it by using the Feature Infrastructure. For example, we can create a new button, delete an existing button, as well as replacing an existing button. Hence I can easily get around with the problem that I had in SharePoint 2007.

In order to hide a button, say the “Open with Explorer”, we will need to create a feature. We start by creating a new folder called “DisableRibbonButton”. Create a new file called “feature.xml” in the new folder and insert the following XML into the file

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="33057CD9-6D14-45c9-83ED-5E1FE066AC92"
         Title="DisableRibbonButton"
         Description="DisableRibbonButton"
         Version="1.0.0.0"
         Scope="Web"
         xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="Manifest.xml" />
  </ElementManifests>
</Feature>

Then create another file called “Manifest.xml” and insert the following XML:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="RemoveExplorerButton"
    Location="CommandUI.Ribbon"
    RegistrationType="List"
    RegistrationId="101">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Library.Actions.OpenWithExplorer" />
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>
</Elements>

The above XML is to remove the “Open with Explorer” button from the Ribbon for all list with type ID 101, hence all the Document Library type. The location “Ribbon.Library.Actions.OpenWithExplorer” is the ID that is registered in the default Ribbon button XML, which can be found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML”

Now we will execute the following Cmdlet using the “SharePoint 2010 Management Shell” to install and active the feature:

Install-SPFeature DisableRibbonButton

Enable-SPFeature DisableRibbonButton –url http://<servername>

After that, go to any document library in your site, click the “Library” tab at the top and you should see the “Open with Explorer” button is now disappeared from the Ribbon.

Friday, 8 January 2010

Notes on Installing SharePoint 2010 Beta 2 on Windows 7 Ultimate

I have just bought a new Sony VAIO laptop for SharePoint 2010 development. It has Windows 7 Ultimate on it and obviously it is 64 bit. Even though there were some problems with the SharePoint 2010 Beta 2 installation, but fortunately I am able to get SharePoint 2010 Beta 2 running on my laptop now without any problem.

I am going to list out the installation steps in this post, as there are lots of article around about the installation steps already. Instead I will list out the problem that I had and how I got around them.

I followed the MSDN article “Setting Up the Development Environment for SharePoint Server” to prepare the installation and most of the things work fine.

For your information, here are the detail of my development environment:

  • Windows 7 Ultimate – 64 bit, with 6GB RAM
  • SQL Server 2008 Standard Edison – with SP1 and latest cumulative updates
  • SharePoint 2010 Beta 2
  • Visual Studio 2010 Ultimate Beta 2
  • Office 2010 Beta
  • No Active Directory

Here are the problems that I had when I setup my SharePoint 2010 development environment.

1. SQL 2008 Install Error: Invoke or BeginInvoke cannot be called on a control

When I run the SQL Server 2008 installation wizard, I got the error message “Invoke or BeginInvoke cannot be called on a control”. After a bit of research, I found the solution mentioned in this post works. All you need to do is minimize all other windows when the installer is running, and make sure the SQL 2008 installer windows is always active by clicking the installer dialog.

Well, this is a weird problem…

2.) Cannot Create New Web Application and Running the Configuration Wizard in Central Admin

This one is easy, just turn off User Access Control and you will be fine.

3.) Visual Studio 2010 Install Error: VC 10.0 Runtime (x86)

I was trying to install Visual Studio 2010 Beta 2 using the ISO file that I downloaded from MSDN. However I was getting an error when the installer try to install the “VC 10.0 Runtime (x86)” component.

After Google for a while, I found this post suggesting using the web installer will fix the problem. I have tried this and it works fine for me.