Good Security Precaution!

April 1st, 2011 No comments

Within 8 hours I checked my Gmail from US and Canada; and sure enough I got the following warning message:

gmail.png

I liked it!

Categories: General Tags:

Adding a Content Type to a Hub Using a Feature

March 25th, 2011 2 comments

The more I work with content types , the more I like to do everything programmatically rather than declaratively using features. Here is a funny thing that may make you scratch your head for a while:

  1. Create a feature that adds a content type to a content type hub.
  2. Publish the content type in the hub.
  3. Let the publishing/subscribe timer jobs run (every hour or so) or manually execute them through Central Admin site.
  4. In a subscribe site collection, check the content type publishing error log.

It errors out saying that you need to install the feature on the subscriber site collection. Although, you don’t need to activate the feature on the target subscriber , I still think the dependency on feature installation on the subscriber site collection is somehow odd!

Whether this is by design or just a bug , I don’t know, but here is the resolution :

Resolution: Add the content type to the hub either through the browser, PowerShell or use a console application for what that matters!Using features to add content types is really not worth the headache.

Categories: SharePoint 2010 Tags:

Now Available for Pre-order: Real World SharePoint 2010 Book

October 17th, 2010 1 comment

The book that I co-authored with other SharePoint MVPs, Real World SharePoint 2010, is now available online for pre-order, though it won’t ship before end of October.
For more information see http://www.amazon.com/Real-World-SharePoint-2010-Indispensable/dp/0470597135

Categories: MOSS 2007 Tags:

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: