The other day, I downloaded the beta for ColdFusion 9.  While waiting for the download, I was looking through some of the marketing copy that Adobe had on their site about the new features for this release.  I about fell off my chair when I saw that not only has ColdFusion 9 increased connectivity to Microsoft’s SharePoint, but they have even built a tag to wrap up the functionality into one nice little package: <cfsharepoint />.

This one little tag is incredibly powerful.  It knocks out all of the painful and cumbersome web services wrappings required to deal with SharePoint’s WSDLs.  Besides having over 50 built-in functions to deal with lists, document libraries, and the like, you can optionally point to other (or custom) WSDLs to access whatever <cfsharepoint> can’t get at by default.

So after reading about this, I just HAD to try it out.  Not surprisingly, ColdFusion makes a routine task like retrieving a list extremely simple.  Here’s my test:

<cfset viewFields = xmlParse("
      <ViewFields>
            <FieldRef Name='Title'/>
            <FieldRef Name='ID'/></ViewFields>
")>
<cfset query = xmlParse("
     <Query>
          <OrderBy>
               <FieldRef Name='ID'/>
          </OrderBy>
     </Query>
")>
<cfset queryOptions = xmlParse("<QueryOptions></QueryOptions>")>

<cfsharepoint action="getlistitems"
              domain="domain.com"
              name="spVar"
              userName="myusername"
              password="mypassword"
              params="#{listName="546585D2-7AC4-493F-8DC5-F089B9EEB0AD",
                        viewName="A8720E14-A847-4255-8527-055D2DD97868",
                        query="#query#",
                        rowLimit="20",
                        viewFields="#viewFields#",
                        queryOptions="#queryOptions#",
                        webID=""
                       }#"
/>

<cfset results="#spVar.listitems.data#">
<h1>Site Punch List</h1>
<ul>
     <cfloop index="i" from="1" to="#arrayLen(results)#">
     <li><cfoutput>#results[i].ows_Title#</cfoutput></li>
     </cfloop>
</ul>

This is very straightforward.  For supported web service methods, you simple specify the method in the “action” attribute of the <cfsharepoint> tag.  In this example, I simply hard-coded my log in credentials, but the tag optionally supports the “login” attribute which can accept a pre-built domain/username/password object.  After that, you just specify the required fields for the web service method (which can be found in Microsoft’s web services docs), and you’re good to go.

Simple.  The only tricky bit, really, is building out the XML required by some of Microsoft’s methods.  However, Microsoft’s documentation of the requirements for these is pretty good, so with a bit of reading you’ll have no trouble at all.

UPDATE: The other day, someone asked a very good question about how to retrive the list/view GUID to use in the cfsharepoint tag.  I’m sure there are better ways of doing this, but here’s a quick and dirty way to do it.  Hope this helps!