SharePoint 2010

SharePoint Lists Web Service

During a recent project I was leveraging the SharePoint Lists Web Service to retrieve information from a list and push it to a Silverlight display.  The list I was using was a heavily customized list with about 35 different views and at least as may fields.  My Silverlight display would provide information like the “status” of the list item based on a number of other criteria.  This status field was stored as a simple “Single line of text” field in the SharePoint list.

The first issue I had to resolve was how to get the right view for the SharePoint list.  The frustration with this is that the Lists Service’s (lists.asmx) GetListItems action has the second parameter “viewName” the documentation on this parameter actually specifies the proper value is a GUID.  I will write another blog about how I retrieved the view’s GUID later, but for now just understand that I did have to take that into account.

After getting the proper view information I now needed to filter the list so that only particular items I was interested in would be returned.  I added the query parameter to perform the filtering as well as adding the viewFields parameter to ensure that I received the fields I expected.

At this point I went ahead and executed my code thinking that I was now good to go and should receive my filtered list items.  On the initial execution an exception was thrown, so I placed a breakpoint on the xml result from the GetListItems call and re-executed.  When I hit the breakpoint I looked at the and noticed the status field was missing.  I allowed the code to continue and when it attempted to access the status field the exception was thrown.  I verified that I had the correct view, view fields, filters etc and nothing looked out of place.

I think downloaded U2U’s CAML Query Builder (a tool I HIGHLY recommend if you are building CAML queries) and tested my query in that.  Interestingly, I noticed that the status field was missing in U2U’s output.  I then modified the query, I removed the <where>…</where> statement, so that all list items would be returned and suddenly the status field appeared.

I reexamined the list item data, and since it had no value in the status field I decided to add one (something that normal users are not allowed to do in the production list).  I executed my query in the U2U tool and noticed that now the status field was available.  Again I went back to the list and removed the status field value, and again the field was removed from my query results.

I have tested this scenario with a number of other lists all using the single line of text field and have noticed similar outcomes, the field is not returned if it has no value.  I have since modified my code to handle the case where the field may not be returned and I use a default “status” value.  I have since noticed that this is pointed out in the commends (second from the bottom at the time of me writing this blog) but is not included anywhere in the documentation.

Best of luck!

Advertisements

SharePoint 2010 Document Set, Create Your Own

In preparing for a demo I wanted to show just how easy and powerful Document Sets in SharePoint 2010 can be.  Using the Public Beta I followed Liam Cleary’s steps to enable documents sets, but realized that an empty Document Set really doesn’t help show the power.  I decided to dive in and see if I could create my own custom Document Set, and here are my successful steps.

Getting Started

Before we go further the important thing to realize at this point is that Document Sets in SharePoint 2010 are a new Content Type for folders.  That being said, like in MOSS/SharePoint 2007 Content Types can/should be extended to fit your needs.

Build Your Document Set Content Type

Before following these steps make sure you have already enabled Document Sets in your Site Settings.  For instructions refer to Liam Cleary’s blog about the document sets.

  1. Go to your Site Settings
  2. Select Site content types from the Galleries section
    Galleries-SiteContentType
  3. Select Create on the Site content type page
  4. Provide a Name for the new Document Set Content Type.  Select Document Set Content Types as the Parent Content Type (if this is not available then you have not followed Liam’s blog successfully).  Choose the Group, or create a new one, that you want this Content Type included in and click OK.
    NewContentType

Your new Document Set Content Type should now have successfully created, but we really have not created anything different from the existing Document Set Content Type.  Next, we will add several documents to this document set that we want to include when one of these are used.

  1. Select Document Set settings
    DocumentSetSettings
  2. In the Allowed Content Types choose the types of Content you want to allow the Document Set to contain.  (Any Content Types you want to create when the Document Set is created should be included in this list).
  3. In the Default Content Select the Content Type you want to include and a “Template”, if allowed, that should be generated.  For multiple items click the Add new default content … link as many time as necessary (or allowed).
    DocumentSetSettings-Advanced
  4. Click OK

You probably noticed that there are several other settings on the page that you can enable/disable/use, but for the purpose of this blog I chose to ignore them.  In future blogs I’ll go back and discuss what some of these options are and how they can be useful.

Use Your Document Set

So at this point you have now created your custom Document Set Content Type and associated documents with it that should be created whenever this Content Type is used.  Next we will actually make use of the new Document Set.

  1. Go to the Document Library where you wish to use the Document Set (if you don’t have one yet then go ahead and create one now.
  2. In the Library Settings (available on the Library Tools:Library ribbon) choose the Advanced Settings.
  3. In Advanced Settings for the Allow management of content types? choose Yes and click OK
    DocumentLibraryManageContentType
  4. In the Content Types section of the Library Settings choose Add from existing site content types
  5. From the Select Content Types choose the name you used for your Document Set and Click OK
    AddContentType

At this point if you want you can also choose to change the ordering of Document/Document Set so that when a user clicks the “New” button they will end up with your Document Set rather than a standard document.

Finally, you can now create your new Document Set, and when the creation completes you should see your custom documents in the newly created Document Set.

NewDocumentSetInUse

NewDocumentSetInUseResult

SharePoint 2010 Standalone Bug

I recently ran the SharePoint 2010 installer, still in Beta, and had no issues during the installation.  My system was configured as a Windows Server 2008 R2 64-bit with a separate Domain Controller.  This was a “clean” server so nothing else was installed.  Next I ran the SharePoint 2010 installer and decided to start by using a StandAlone install, I figured that if this worked then I could proceed to a Farm Installation.

Before I go any further let me commend Microsoft on improving the SharePoint installation process.  I really appreciate the fact that they have now configured the installer to handle installing all pre-requisites instead of just halting and requiring the user to perform these steps.

After the installation completed I ran the SharePoint Configuration wizard, but when I got to the last step I suddenly got an error:

“Unrecognized attribute ‘allowInsecureTransport’. Note that attribute names are case-sensitive. (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebClients\Profile\client.config line 56) —> System.Configuration.ConfigurationErrorsException: Unrecognized attribute ‘allowInsecureTransport’. Note that attribute names are case-sensitive. (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebClients\Profile\client.config line 56)”

I checked the file (client.config) and sure enough the line appears as described in he error message above.  Not sure if the installation was now broken or not I attempted to access Central Admin, SUCCESS.  Next I looked at the SharePoint Web Applications and noticed a Team Site on port 80 had been created.  I checked this site to see if it would work, SUCCESS!

Finally I decided to push my luck and see if a Visual Studio 2010 Web Part could be created and deployed to the new SharePoint 2010 environment.  SUCCESS!

To date I have not seen any issues resulting from the error message, I am still testing and will update this posting if I run into any issues.

UPDATE 11/24

The Microsoft Team has a resolution for the issue described above.
http://blogs.msdn.com/sharepoint/archive/2009/11/19/installation-notice-for-the-sharepoint-server-public-beta-on-microsoft-windows-server-2008-r2-and-microsoft-windows-7.aspx

jQuery to SharePoint Web Services

Recently I have been working on a Google Maps integration for SharePoint and one of the desired capabilities was to include items from SharePoint lists on the map.  The solution was not going to leverage the AJAX .NET capabilites and would instead be built using standard .NET and jQuery.  This presented the major challenge, while we could convert the lists into RSS, GeoRSS, and KML feeds they all required authentication to access these feeds, something that Google Maps does not support in the GGeoXml object.  Google Maps are heavily javascript focused so we couldn’t use the SharePoint API to access the items directly especially since we wanted to avoid post backs to the server, and javascript arrays would likely run out of space give the number of possible items.  This really left us with one possible solution, javascript calls to the SharePoint Web Services.  Fortunately, talking with one of my co-workers he pointed me to a nice, somewhat limited, jQuery plugin for the SharePoint web services available here:

http://www.sympraxisconsulting.com/Demos/Demo%20Pages/SPjQueryWebServices.aspx

Using this service I have been able to access the current web’s lists and items from those lists.  Here is an example of how I have used this plugin to retrieve the lists and populate a selection box, their code for the button clicks are also available.

My Code

$(“.list_select_cell”).html(“<img src=\”/_layouts/images/ewr133.gif\” alt=\”Loading lists\” />”).SPServices({
operation: “GetListCollection”,
completefunc: function(data, status) {
var mySelectBox = “<select size=’5’ id=’list_select’>”;
$(data.responseXML).find(“List”).each(function() {
mySelectBox += “<option value=’” + $(this).attr(“Title”) + “’>” + $(this).attr(“Title”) + “</option>”;
});
mySelectBox += “</select>”;
$(“.list_select_cell”).html(mySelectBox);
}
});

 

So what is really happening here?

$(“.list_select_cell”).html(“<img src=\”/_layouts/images/ewr133.gif\” alt=\”Loading lists\” />”).SPServices({…

 

In the above code we have selected a location that currently exists in our page’s DOM and have added the ewr133.gif, the same gif SharePoint uses when processing Site creations.  So basically you specify the DOM object you want to effect while making the asynchronous calls to the SharePoint web service.  You do not have to add or remove text from a DOM object, you could also choose to show or hide an object, that is based on your needs.

operation: “GetListCollection”

Here you are specifying the service you are calling.  These match the name of the asmx file provided by SharePoint, in this case the call is actually going to the GetListCollection.asmx service.  Only certain service calls are supported as the jQuery library is not an all inclusive library.

 

completefunc: function(data, status) { …

This specifies the action to take when the asynchronous call completes.  The first argument provided to this function is the XmlHttpRequest object, thus in order to gather any information from the response you must parse the responseXML.  At the end of this function I recommend, if you changed the DOM object’s html as part of the “while processing” action that you now set the value to something useful to the user.

So now you can access your lists, and your list items from Javascript and you don’t even need to perform a standard PostBack.

Some limitations

One of the biggest limitations I experienced with this tool is that the plugin assumes you want to use the “current” SharePoint web when retrieveing lists, and also assumes that any list you are accessing is stored in the current web.

Conclusion

This plugin while limited is EXTREMELY stable for an 0.X version, and saved me a number of hours of custom coding WCF services, or building my own version of this plugin.

Update (8/25/2009)

One day after originally publishing this post Marc D made the changes necessary to overcome what I have listed above as a limitation.  I have not had the opportunity to include these changes into our solution as it is no longer in the development phase of its life cycle but I do plan on using Marc’s latest version in the next iteration.

If you are interested in Marc’s tool you can get the latest version on Codeplex here:
http://spservices.codeplex.com/

Thanks Marc for reading!

More information about SharePoint 2010 Revealed

A fellow SharePointer, Joel Oleson, posted a very nice summary to the recently released SharePoint 2010 system requirements.

Two items have really stood out as I reviewed the information.

First, SharePoint 2010 will require a 64-bit platform to run correctly.  Most likely this is due to limitations of memory and providing enough resources for the SharePoint Web Application Pools.  However, it does seem to follow the recent trend Microsoft has established with the release of OCS R2 and Exchange 2010 which both require 64-bit operating systems.

Second, was the requirement to run Server 2008, 64-bit of course.  This will of course provide the latest version of IIS, but may also be a helpful to Microsoft Hyper-V to start cutting into the VMWare market share.  Given that Server 2008 comes with “free” Hyper-V capabilities why would companies then look to spend additional funds to purchase another virtualization capability.

One last significant advancement from Microsoft that has gone a little under the radar, but I believe is going to be a key capability is the release of Service Pack 2 for the Microsoft Office 2007 suite.  This service pack as attempted to overcome some of the issues experienced when using Office 2007 with SharePoint 2007 that has forms enabled.  Overcoming this issue will be critical as Microsoft has announced that SharePoint 2010’s security will be claims based thus requiring greater support for authentication schemas that do not use Windows Authentication.

SharePoint 2010, or 14 Authentication Revealed

As the SharePoint conference approaches, October this year, we are beginning to look to the next generation of SharePoint and what it will provide and how it will work. Although this is an older article, 10/2007, as we look forward this is going to be a critical change for us to deal with. Microsoft has announced that SharePoint will use “Claims-based authentication” in the next version. This should really not be that surprising, as I have worked with many of their identity and lifecycle professionals they have often pushed away from Active Directory Domain Trusts and encouraged AD Federation, AKA claims-based authentication.
Now we look to SharePoint 2010 to be the next system using essentially Federation of user accounts to perform security activities. The one key thing I will be looking for at the conference is if the Client Integration capability which falls away with SharePoint 2007 through Federated Services is still available in 2010.