Archive

Archive for the ‘SharePoint 2010’ Category

Querying Document Sets Using SPSiteDataQuery

September 26th, 2010 1 comment

In SharePoint 2010, a document set is just what it is shouting at us- a bundle of documents! Agnes (SharePoint MVP) has a nice and short post here about how to setup document sets. If you activate a site collection scoped feature called  “Document ID Service”,  document sets, like any other document in a site collection, are assigned a unique ID (i.e. “DHSD-5-14”) which can be used to retrieve them  independent of their location in the site collection. An awesome feature of SP2010!

A pretty common integration scenario is when a BizTalk orchestration (or CRM Workflow) needs to pass a document set id to your WCF service (installed in ISAPI folder in the WFE) and your service needs to return the document library URL based on that document set id. This way BizTalk can upload multiple documents to that document set. Let’s assume that the document library and the document set are already created and BizTalk is aware of them.

How would you go about this?

I haven’t found an easy way to do this through SharePoint object model .Obviously, one inefficient way to do this is to loop through all the document libraries and find the document set , like below:

[CSharp]
using (SPSite site = new SPSite(“http://foo”))
{
using (SPWeb web = site.OpenWeb())
{

//Bad Code
foreach (SPList list in web.Lists) {
if (list.ContentTypesEnabled)
{
SPContentType spCtype = list.ContentTypes[“Document Set”];
foreach (SPListItem item in list.Items)
{
if (item[“Document ID”].ToString().Contains(“DHSD-5-14”))
string url = string.Format(“{0}/{1}”, list.ParentWeb.Url, list.Title);
}
}
} //End of SPWeb using
}//End of SPSite using
[/CSharp]

As you can see, when you activate Document ID Service, each document set (they are SPListIItem at the end of the day, right?), gets a new column called “Document ID” which by examining the SPListItem[“Document ID”], I am finding the one that I am looking for.

Another (and better) way is to use the SPSiteDataQuery to query the entire SPWeb (and all the child subsites) for that document set.

[CSharp]

using (SPSite site = new SPSite(“http://foo”)) )
{
using (SPWeb web = site.OpenWeb())
{
SPSiteDataQuery query = new SPSiteDataQuery();
query.Webs = ““;
query.Lists = ““;
query.Query = ““;
query.Query += “Document Set“;
query.Query += “” + “DHSD-5-14” + ““;
query.Query += “
“;
DataTable dt = web.GetSiteData(query);
DataView dv = new DataView(dt);
if (dt.Rows.Count == 0) { // No donuts! }
DataRow dr = dt.Rows[0]; //There is always one row, if any!
Guid listId = new Guid(Convert.ToString(dr[“ListID”]));
SPList targetDocLib = web.Lists[listId];
string url = string.Format(“{0}/{1}”, targetDocLib.ParentWeb.Url, targetDocLib.Title);
} //End of SPWeb using
} //End of SPSite using

[/CSharp]

If you have worked with SPSiteDataQuery before, most likely you are aware that it’s a bad ass API. A simple lowercase or or spelling mistake either results in errors or(even worse) returning no result. In my case I had issues querying document sets.

As you can tell, I am not passing any ViewFields to the SPSiteDataQuery.  These are not required as ListID, as well as WebID and SPListItem ID, are returned by default. You will also notice that I haven’t looped through all of the returned data rows, since if my query returns any result, there should be only one document set with the id of  “DHSD-5-14”.

The most important thing, thought, is the use of  _dlc_DocId in the query which is being referenced in the where clause of my CAML query. This is the static name for the Document ID column and  took me a little while to figure it ou. Thankfully, using the SPSiteDataQuery class, I was able to quickly find my document set and extract the URL of its parent document library.

Categories: SharePoint 2010 Tags:

Toronto SharePoint Summit 2011 Call for Speakers

September 18th, 2010 No comments

Hi Everyone,

On behalf of the SharePoint Summit Board of Directors, I am excited to send out this call for speakers for SharePoint Summit 2011 which is being held in Toronto from January 31 to February 2, 2011.

This is a great opportunity for you to showcase your expertise and knowledge of SharePoint with your peers that are also interested in SharePoint technology and implementing best practices to meet their organizations business needs.

If you wish to submit a session, please go to: http://www.sharepointsummit2011.com/Toronto/call_speakers.asp. The deadline for submissions is October 4, 2010.

With over 500 visitors expected to attend SharePoint Summit 2011, this will be one of the most important SharePoint event for the community.

All submitted applications will be presented to the selection committee which has been created in order to ensure that the topics and speakers being submitted will bring value and help attendees in optimizing their SharePoint installations.To meet the needs  we want to target presentations for both technical and business-oriented audiences.  This means we are looking for presentations that will not only help developers and IT management plan and architect successful SharePoint solutions, but we also want to pay particular attention to topics that will help business decision makers and information architects ensure that they can use SharePoint as a platform to drive business value.

Please take a look at the suggested topics below as you prepare your application submission.  Consider also whether your presentation is directed to those who are new to SharePoint (Level 100) or those who are more advanced in their knowledge and expectations (Level 300).  We are looking for a good mix of content to address attendees with differing levels of experience.
Presentations will be categorized by Level, target Audience, and general Topic:

LEVELS
100 – Introduction to SharePoint
200 – Intermediate SharePoint
300 – Advanced SharePoint

AUDIENCES
Developer
Business Manager
Information Architect
Project Manager
IT Management

TOPICS
Knowledge Management
Governance
Information Architecture
Development
Case Studies
Implementation Methodology
Change Management
Tools and Techniques

For more information on SharePoint Summit 2011 and becoming a speaker please do not hesitate contact me by leaving a comment in this blog post.

Categories: SharePoint 2010, UG/CodeCamp Tags:

Reza Alirezaei is a SharePoint 2010 MCPD, MCITP & MCTS!

July 30th, 2010 10 comments

I took all 4 beta versions of SharePoint 2010 exams in three days in May 2010. My transcript  finally showed up, and it shows that I have successfully passed all four exams. So, I am officially a SharePoint 2010 MCITP, MCPD and MCTS (in both Application Development and Configuration).

mcp.pngmcpd.pngmcitp.pngmcts.png

Categories: General, SharePoint 2010 Tags:

Exclusion Filters in User Profile Synchronization

July 25th, 2010 5 comments

Assuming that you have already setup a profile synchronization connection, let’s say you need to configure the service to exclude users whose accounts have been disabled in Active Directory. Or, the groups which contain the word “RAS” in them.

How would you do this? The answer is exclusion filter.  A feature that enables you to exclude users (or group) during the synchronization process.

First you need to get there:

1) Browse to Central Administration Site > Manage Service Applications > User Profile Service Application.
2) On the Manage Profile Service: User Profile Service Application  page, click the  Configure Synchronization Connections. This will take you to a page where all the synchronization connections are already setup.


3) Select the connection you want to filter, and then from the ECB menu, click Edit Connection Filter.

The Edit Connection Filters page is where you can select a user or group property for which you want to apply a synchronization filter and configure it. The page is divided into two sections: Exclusion Filter for Users and Exclusion Filter for Groups. Titles are pretty self-explanatory!

4) In the users section, click the Attribute list drop down and select userAccountControl flag.

Adsiedit.msc displays the value of this flag in decimal for a disabled account (John Doe):

5) Select Bit on equals as the operator,and then type 2 for the filter value. Don’t forget to click Add to add the filter condition to list of existing conditions.

* Choose All apply (AND) when you need all of the conditions to be true for the exclusion filter to kick in.
* Choose Apply any (OR) when you need only one of the conditions to be true for the exclusion filter to kick in.

6) In the groups section, click the Attribute list drop down and select DisplayName.
7) Select Contains as the operator,and then type RAS for the filter value. Again, don’t forget to click Add to add the filter condition to list of existing conditions.

Your page should look like this:

.8) Click Ok where your done.
9) Start a full synchronization.

Once the synchronization is completed, the John Doe guy and all the groups containing the word “RAS” shouldn’t be imported to SharePoint.

Categories: SharePoint 2010 Tags:

A Renewed MVP Again!

July 19th, 2010 4 comments

Gotta love Canada Day that’s the anniversary date for my MVP award!

It’s a late kind of announcement, but just a quick note that I was awarded MVP status again.  This makes it my fourth year as a SharePoint MVP and I’m looking forward to another exciting year of helping the SharePoint developer community through my presentations, upcoming new book (will be announced later), articles and blog posts.