SharePoint 2007 Dynamic Filtered Lookup

Tag: sharepoint-2007 , argument-dependent-lookup , filtered-lookup Author: fsyumin Date: 2011-04-23

Good morning, all. I'm looking for help with setting up a library template in SharePoint 2007. Here are the details:

  • I have a parent site with several subsites.

  • I want to set up a library template that can then be placed on each subsite. These libraries are going to pull from a series of centralized lists on the parent site in order to provide metadata options. This way, I only have to maintain one set of lists and the maintained list information will be available to each library.

  • Because the libraries exist on subsites of the main site, I can't use simple lookups. A regular lookup column type only works for lists within the current site.

  • I have access to the filtered lookup column type, and it seems like the right choice because it allows me access to the centralized lists on the parent site.

I'm looking to have the user prompted when uploading files to a library based on this template. After selecting the file, the user is presented with the list of metadata choices to fill out.

  • I want to have the first filtered lookup provide the user with a list of choices. This currently works properly.

  • I want the second filtered lookup to provide a filtered list of choices based on the selection in the first filtered lookup.

  • There's a section for a CAML query filter string, and this is where my hangup is. How does one write a string to reference a field as opposed to a static value?

This is what I've tried. In the Apply Query Filter field, I have put:

    <FieldRef Name='Category' /><Value Type='Lookup'>Blue</Value>

This works, but only provides results where the value is Blue, a static string. I'm looking for a way to reference the actual selected value of Category. It would be something to the effect of:

    <FieldRef Name='Category' /><Value Type='Lookup'>[Category.Value]</Value>

My hangup right now is I don't know the proper syntax, or if such syntax even exists.

Many thanks for your suggestions. I'm not tied to this approach, so if there's another way to accomplish the same goal, I'll be happy to entertain it.

Other Answer1

This is an old question, but I just now stumbled upon it - In case the user still needed help, I figured I'd answer. You can do this 2 ways: 1. Callback 2. Querystring

Either way will work fine and will provide the data to your query. The trick is to add a lookup parameter, something like:

<ParameterBinding Name="Category" Location="Control(Filter1)" DefaultValue=""/>


<ParameterBinding Name="Category" Location="QueryString(Filter1)" DefaultValue=""/>

You can then reference the variable in your CAML query the SPDataSource selectcommand:

    <FieldRef Name='Category' /><Value Type='Lookup'>{Category}</Value>

The variable name above of {Category} is the name provided by the ParameterBinding.

Hope this helps.


Thanks, TeckniX, for taking the time to respond to the original post. My question for you relates to the first two lines of code you presented. Where would I add the lookup parameter? I sadly fall into the class of the faux-grammer, using SharePoint from a fairly superficial level. As a result, I don't have much experience poking about beneath the hood. I have SharePoint Designer installed, but aside from that, I don't know where to begin. If you are able, can you please direct me a bit further?