The inclusion of REST in SP2010 has given us an easy way to reference lists external to the site collection - and cross-site lists too of course! The purpose of this post is to give a quick run down on creating the REST connection as data source and building a data view web part to display the result. The post is probably aimed more towards a non-technical audience but may prove useful for developer / consultant types.
First thing to note is REST must be enabled on your environment so before you go any further, check that the service is running through your web browser. To do this, simply paste the following into your browser and replace the bracketed variables with your SP URL and the name of the list you wish to use.
If that returns a result in browser that looks strikingly like an RSS feed - then great, the service is working. If not, then ask your SP Admin nicely to get REST enabled (or have a go yourself if you have access) and the SPDevWiki has a good article on how to do so here
Techy note: As an alternative to REST you can follow the same principles of this article and use a the list.asmx web service and a SOAP connection as your data source. Personally I find this method easier to build your data view web part but both methods have their merits.
So assuming REST is enabled - we will move onto creating the connection into SP Designer.
First, open up SP Designer and go to the data source window.
Select 'REST Service Connection' from the ribbon to create a new REST query. On the 'General' tab enter a relevant name and then on the 'Source' tab under 'Select Connection Info' use the following syntax to specify the URL:
Replace [yoursharepointURL] with your address and [LISTNAME] with the name of your list. Randy Williams has a good article on using REST in SharePoint 2010 so check that for further information.
The main thing to understand here is the structure of the URL and how to define which list it points to. The intention of this article is to explain how to reference a list on a different site collection but you could use any REST enabled data source for the same purpose.
An issue I encountered when playing around is that windows authentication didn’t seem to work when trying to build a data view web part - so if you encounter this then I suggest specify your domain account in the 'Login' tab. See my brief post on this here.
The next thing to do is create a blank web part page in order to display the new data source. Go to the 'Site Pages' library or any pages library within your site and select 'Web Part Page -> Blank Web Part Page' from the ribbon as shown in the screen below.
Now add the data view web part to the empty web part zone. Make sure the focus is in the web part zone in order to see the 'Insert' ribbon.
From the 'Insert' ribbon select the 'Data View' button and then 'Empty Data View'. You could select the REST connection by scrolling down the drop down list but I had a few issues with that and prefer to define it in a second step - if it works for you then by all means do it!
If you followed my method of adding an empty data view web part then you see a web part like this.
Right click the web part and select 'Select a Data Source' from the context menu.
Now select the REST connection to add the data connection to the Data Source details panel and begin building the data view.
If everything went smoothly then you should see a data in the data source details panel similar to my screen below. If you encountered a 'non-specific error' then please see my short post here and force the connection to use your credentials and not windows authentication. I haven't seen a way around this as yet but will keep an eye out.
Now the data connection is setup it’s just a matter of selecting what fields to display on the web part. There are two ways of doing this and it should be a matter of preference as to which you use - either select 'Add/Remove Columns' from the 'List View Tools - Options' ribbon or select the columns from the data source details panel and drag them onto your web part.
You should end up with a data grid similar to the mine below depending on how many columns you selected and the structure of your data.
How you build your data view depends the structure of your source data and it's beyond the scope of this article to detail the various methods but the point here is we have the ability to use data from a list external to the site collection. This is a big plus if your environment has multiple SharePoint deployments for various functions such as a corporate intranet and an Office Business Application (OBA) - and you need to lookup data between them. It also provides an easier way to reference lists cross-site and I find this method easier than using SharePoint's lists.asmx web service and SOAP - but that may just be a personal preference!
Hopefully the post is useful to those who haven't worked with the data view part before and for those who have - hope there weren't too many screen clips!
As always feedback and questions are more than welcome!