Linking to Documents with a Roll-up DataForm Web Part

Say you want to make a roll-up webpart of all the word documents in a bunch of subsites on SharePoint 2010. Well, you could use the Content Query Web Part and modify the XSLT to filter out everything but word documents. Or, you could fire up SharePoint Designer and pull out the handy-dandy DataForm Web Part.  There’s really nothing new going on here that hasn’t been covered in other blogs. A great resource for getting your head wrapped around the crosslist dataform webpart is Marc Anderson’s blog. The thing that confuzzled me, though, is that when you switch the datasource from a single list, to a recursive crosslist, your data is returned with a number, followed by a semi-colon, followed by the pound sign, followed by the actual data that you want. Argh. Not good, and more Google-spelunking led me to Laura Rogers (@wonderLaura) who pointed me in the right direction on this issue. She’s linking to list items, whereas I’m linking to documents themselves. If you want to link to the documents themselves, it’s a fairly minor change though. Just change this:

{concat('/',substring-after(@FileDirRef,'#'),'/Dispform.aspx?ID=',@ID)}

to this:
{concat('/',substring-after(@FileDirRef,';#'),'/',@LinkFilename)}

(Note, be sure to add the LinkFilename to your selected fields.)

Voila – the name of the document linked to the document itself, no matter which subsite it’s found in.

About these ads
Leave a comment

2 Comments

  1. Deanna:

    Thanks for the mention! Just a small suggestion…

    Always be as specific as possible when you substring things. In this case, it’s simply including the semicolon in your test string:

    {concat('/',substring-after(@FileDirRef,';#'),'/Dispform.aspx?ID=',@ID)}
    

    It may seem a little silly or hair splitting, but it’ll save you at some point, trust me.

    M.

    M.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: