December 16, 2004

Getting Sharepoint subsites to communicate part 2

Following my previous post, I have taken the connections between subsites further using connected data view web parts, where one web part provides an input to filter the data presented in the second web part.

Scenario: http://server/subsite1 holds a master list of projects, and a document library of documents for each project. http://server/subsite2 is to provide a subset of the project list, and when an item is selected, provide a list of the documents for that project. (Ideally it would provide links to the actual documents and enable them to be downloaded, but that issue is yet to be overcome - it turns up in plenty of sharepoint blogs.)

Approach: the above is accomplished relatively easily with data view web parts and FrontPage 2003. The only tricky bit that I found was setting the connection parameters to retrieve the correct view. (Note that the web part only retrieves the first page of the view on the other site, so if the list is very long you may need to create a unique view with a large item limit to ensure that all of the data is returned. And you will need to find the GUID of the view to use as a parameter in the connection.)

References: the following articles provide a good basis to understand what is going on:

Building XML data-driven websites with FrontPage 2003 provides a good overview of the data view web parts and using the data source catalog in FrontPage;

Web Services Description Language (WSDL) explained is an older article, but I found it very informative when looking at the code behind the cross-site queries.

Result:

Screenshot - connected DVWP's retrieving items from another sharepoint site

This is a screenshot of subsite2. The web part at the top of this screenshot retrieves a subset of list data from subsite 1. Selecting an item in the list provides an input parameter to the second web part, which filters the items in a document library on subsite 1 accordingly, and presents the results. (The two sites concerned are both at the same level in the site hierarchy, not parent-child sites.)

Now onto how to accomplish the connections.

The first step is to connect to the data source using the data source catalog - this has been covered in the Frontpoint blog, the relevant article is linked in my earlier post here.

In my case, I wanted DVWP#1, which provides a list of projects, to influence DVWP#2, which is providing a list of drawings. First, use the directions in the above blog post to make a age containing teh two web parts, and get both web parts to retrieve the information that you are after. The data in DVWP#1 can be filtered as desired by going to Data View Properties... and setting the Filters as required. DVWP#2 will not doing any filtering until after a web part connection is established, so the data you see in FrontPage will not necessarily look like the final view that you are after.

Open the page you want to work on in FrontPage, right-click the second web part and select Web Part Connections... This opens the Web Part Connection Wizard. The web part you have selected will be the source, then select an action, in my case Modify using parameters from... Click next, and select the target web part (which is the other web part on the page) that will provide the filter criteria. The 'target action' is Provide data values to... Click next. This brings you to this screen:

Web part connection wizard

Select the column in target web part that you want to use as the input parameter. (In my case this is a project number.) Click next. If you want the first web part to highlight which item is selected, tick the box Indicate current selection using... And you are done.

Now set the filter criteria on the second web part. Right-click the web part and pick Data View Properties..., data view details appear in the task pane. Click on Filter, and set the criteria that you want. Note that the input paremeter passed in the web part connection is available as a value to use in the filter criteria:

Filter dialog using input parameter

Save the page, and that's it! Now you have two web parts retrieving items from another site, and the first one providing filter values to the second.

Some related notes 1) if you pick the first web part when setting up the web part connection, the process is much the same but the source and target are reversed and consequently the actions are reversed as well, giving the same end result; 2) if your cross-site connection requires a login, consider setting up a separate account just for this purpose with minimal rights (i.e. 'Reader').

And finally, I would love to know how to retrieve files from a document library across sites. By adding the document library to the data source catalog with Manage catalog..., I have successfully set up a web part that links to the relevant documents with a full absolute URL. And as I have the correct permissions, I can use this web part to retrieve the documents from the other site. But the data sources added with 'Manage catalog' reside with the Frontpage installation, not the sharepoint installation, so this web part will not work for other users of the site. So a web part is needed as a go-between to provide the correct login for the source site. This works OK for attachments to list items, but at this stage does not appear to be available for documents in document libraries. Ughh!!

If you find this post has been helpful, please leave some feedback.

Posted by Jeffrey to the Sharepoint category at 04:09 PM | Comments (0)