none
CQWP filtering for custom fields (Site Directory 'Sites' List)

    Question

  • This was actually a continuation of a question that was mentioned in an earlier earlier that I need further help on.

     

    I am attempting to use the CQWP (Content Query Web Part)  for displaying information from the 'Sites' list that is created with the Site Directory enterprise site template. I am wanting to show the different sites and be able to filter the results.

     

    I am able to do this by using the ListsOverride property to pull from a 'Sites' list type. I am also able to use the AdditionalFilterFields property to add the fields from the list like Country, Region, and Division. So far so good.

     

    The problem I am having is that I've added a couple of extra columns to this list - 'Site Type' for instance. I am able to use the CommonViewFields property to query the info and display it through the XSL, however, when I add it to the AdditionalFilterFields, I do not get the expected results. The 'Site Type' column shows up in the list, but if I enter a value (that I know should produce results), I get 'your query does not return any results...'.

     

    Just wondering if anyone else has had success in using the AdditionalFilterFields property for custom fields, or if there is something particular about the Site List that is fowling this up.

     

    TIA

     

    -James

    Wednesday, May 30, 2007 2:18 PM

All replies

  • Ok, so as an update to this, I've tried a few more things. I wanted to see if for some reason the CQWP was just not able to see those new fields (even though I can get them to show up through the XSL). So, I tried using the QueryOverride property to see if I could filter the results with my custom fields from there. I used the following property name line in the webpart file:

     

    Code Snippet

    <property name="QueryOverride" type="string"><![CDATA[<Where><Eq><FieldRef Name="Site_x0020_Type" Nullable="True" Type="Choice"/><Value Type="Choice">Project</Value></Eq></Where>]]></property>

     

    ...where Site_x0020_Type is the internal name of my column and Project is the value I was looking for. I saved the file and imported the webpart and - voila! The results were returned as expected.

     

    Now this is all fine and dandy, but I still want to be able to use the AdditionalFilterFields property to let the user select the query values dynamically from the drop-down menus, rather than having to hard code a specifc webpart file for each query scenario.

     

    Still searching to see why AdditionalFilterFields isn't working...

    Wednesday, May 30, 2007 10:02 PM
  • Ok, so another update.

     

    At first I was concentrating on one custom field that I was using, which happened to be a 'Single line of text' field (Text enumeration). This field was 'Cost Center'. This wasn't working with the AdditionalFilterFields no matter what values I entered. However, I went ahead and put a different custom field, which happened to be a 'Choice' field, in the AdditionalFilterFields. I entered information to filter on that field, and it worked! So now it seems like only Text fields are having the problem if they are custom - because I tried filtering on 'Title', which is of type Text, and it worked.

     

    Again, if anyone's experienced this, I'd be happy to find out what you might have done to fix. Otherwise, I'll keep this updated.

    Thursday, May 31, 2007 3:37 PM
  • I am facing the same issue. Glad to know that I'm not alone Smile Your solution of QueryOverride works great but I also want the user can change the filter so I tried to add a hidden calculated column that makes the comparison and then filter on that field and doesn't work Sad

     

    I've realized that filter works well with custom fields of type number, datetime and boolean(also with any type if it's a built-in field) but it doesn't work if the custom field is of type Text or Calculated.

    Friday, November 23, 2007 9:46 AM
  •  jmgscott wrote:

    Ok, so another update.

     

    At first I was concentrating on one custom field that I was using, which happened to be a 'Single line of text' field (Text enumeration). This field was 'Cost Center'. This wasn't working with the AdditionalFilterFields no matter what values I entered. However, I went ahead and put a different custom field, which happened to be a 'Choice' field, in the AdditionalFilterFields. I entered information to filter on that field, and it worked! So now it seems like only Text fields are having the problem if they are custom - because I tried filtering on 'Title', which is of type Text, and it worked.

     

    Again, if anyone's experienced this, I'd be happy to find out what you might have done to fix. Otherwise, I'll keep this updated.

     

    have you figure it out? i am facing same issue

    Wednesday, May 21, 2008 12:13 AM
  • I am also trying to filter a content query web part. I actually want to show a different content type based upon a parameter on the url but I guess this is quite similar to what you guys have been discussing.

    I've read that you cant connect the CQWP out of the box but there are ways to do it:

    http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx

    Thinking about this though, I dont really want to return all documents for all content types and then filter that list as the initial dataset would be very large and potentially slow to load.

    Would appreciate your thoughts on this.
    Monday, July 14, 2008 1:25 PM
  • Monday, February 20, 2012 11:52 AM