5

i am working on a team site collection, and i added a Content Query web part. then i did the following:-

  • I export the content query web part.

  • I edit the exported web part inside SP designer .

  • Then I defined a QueryOverride filter as following (I did this since I want to filter based on two separate content types and check if their site columns matches the login user):-

Query:

<property name="CommonViewFields" type="string" />
        <property name="QueryOverride" type="string" >
        <![CDATA[
        <Where>
  <Or>
     <And>
        <Eq>
           <FieldRef Name="ContentType" />
           <Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value>
        </Eq>
        <Eq>
           <FieldRef Name="Technical Delivery Risk/Issue Owner" />
           <Value Type="Integer"><UserID Type="Integer" /></Value>
        </Eq>
     </And>
     <And>
        <Eq>
           <FieldRef Name="ContentType" />
           <Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value>
        </Eq>
        <Eq>
           <FieldRef Name="User Support Delivery Risk/Issue Owner" />
           <Value Type="Integer"><UserID Type="Integer" /></Value>
        </Eq>
     </And>
  </Or>
</Where>]]>

        </property>
  • Then i added the modified web part to the site setting >> web part.

  • Finally i added the web part to the site collection home page.

  • But the filter did not work, and I got the following exception on the web part setting

"some properties in this Web Part are not available because they are configured to have fixed values"

Screen shot of the error:

enter image description here

so can anyone adivce on this please ?

Thanks

EDIT i modified the query to be using the Internal names for the site column and the content type ids as follow:-

<property name="QueryOverride" type="string" >
        <![CDATA[
        <Where>
  <Or>
     <And>
        <Eq>
           <FieldRef Name="ContentType" />
           <Value Type="Text">0x01030039A425F609A70A44BA580AF4A69CB18802</Value>
        </Eq>
        <Eq>
           <FieldRef Name="Technical_x0020_Delivery_x0020_Team" />
           <Value Type="Integer"><UserID Type="Integer" /></Value>
        </Eq>
     </And>
     <And>
        <Eq>
           <FieldRef Name="ContentType" />
          <Value Type="Text">0x01030039A425F609A70A44BA580AF4A69CB18803</Value>
        </Eq>
        <Eq>
           <FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" />
           <Value Type="Integer"><UserID Type="Integer" /></Value>
        </Eq>
     </And>
  </Or>
</Where>]]>

        </property>

but this will not return any result even i have items that satisfy the query ..can anyone adivce ?

EDIT - 2

i wrote the following query :-

<property name="QueryOverride" type="string" >
         <![CDATA[
        <Where>
  <Or>
     <And>
        <Eq>
           <FieldRef Name="ContentTypeId" /> <Value Type="ContentTypeId">0x01030039A425F609A70A44BA580AF4A69CB18802</Value>
        </Eq>
        <Eq>
           <FieldRef Name="Technical_x0020_Delivery_x0020_Team" LookupId="TRUE" />
    <Value Type="Integer"><UserID /></Value>
        </Eq>
     </And>
     <And>
        <Eq>
           <FieldRef Name="ContentTypeId" /> <Value Type="ContentTypeId">0x01030039A425F609A70A44BA580AF4A69CB18803</Value>
        </Eq>
        <Eq>
           <FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" LookupId="TRUE" />
    <Value Type="Integer"><UserID /></Value>
        </Eq>
     </And>
  </Or>
</Where>]]>
        </property>

where i am providing the CT ids & the column internal names, but this will not return any result. although i am having many items that have the defined CTs and the related site column =is equal to the login user ? can anyone adivce ?

---------EDIT 3-------

now for testing purposes i tried the following inside the web part's QueryOverride tag. where i specify to use the CT names instead of their ids:-

<property name="QueryOverride" type="string"><![CDATA[<OrderBy><FieldRef Name="Created"  Ascending="FALSE" /></OrderBy><Where><Or><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Eq><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Eq></Or></Where>]]></property>

and it showed all the items that are defined inside the specified CTs.which is fine.

but if i try to replace the above to check for site columns , then i will not get any result. for example this CAML query will not show any results:-

<property name="QueryOverride" type="string"><![CDATA[<OrderBy><FieldRef Name="Created"  Ascending="FALSE" /></OrderBy><Where><Or><Eq><FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" LookupId="TRUE" /><Value Type="Integer"><UserID Type="Integer" /></Value></Eq><Eq><FieldRef Name="Technical_x0020_Delivery_x0020_Team" LookupId="TRUE" /><Value Type="Integer"><UserID Type="Integer" /></Value></Eq></Or></Where>]]></property>

now even if i use inner <And></And> tags for the query that is working well, the query will stop working. for example the following will not return any results :-

<property name="QueryOverride" type="string"><![CDATA[<OrderBy><FieldRef Name="Created"  Ascending="FALSE" /></OrderBy><Where><Or><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Eq></And><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Eq></And></Or></Where>]]></property>

now i am not sure why the first query worked , while the second and third ones did not work ? and at the end is there a way to filter the list items to be as follow:-

  • have CT A + site column A = login user + status= "in progress"

OR

  • have CT B + site column B = login user+ status ="in progress"

---EDIT 4----

now i deine the site column inside the commonview fields,, here is how my web part looks like:-

 <property name="CommonViewFields" type="string">{3d0722a8-5b0f-4027-b926-2d3e730ce80a},Lookup;{68bd4d83-dbfa-4e0a-af37-76c0a0056ae8},Lookup</property>

  <property name="QueryOverride" type="string">
       <![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Eq><Eq><FieldRef ID="{68bd4d83-dbfa-4e0a-af37-76c0a0056ae8}" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Eq></And><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Eq><Eq><FieldRef ID="{3d0722a8-5b0f-4027-b926-2d3e730ce80a}" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Eq></And></Or></Where>]]>
       </property>

but still no results is being returned ...

---- EDIT 5----

I have added this to the web part:-

<property name="CommonViewFields" type="string">{3d0722a8-5b0f-4027-b926-2d3e730ce80a},Lookup;{68bd4d83-dbfa-4e0a-af37-76c0a0056ae8},Lookup</property>

then i Import/Export it again and i added the QueryOverride tag as follow:-

<property name="QueryOverride" type="string" >
        <![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Eq><Eq><FieldRef Name="Technical_x0020_Delivery_x0020_T" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Eq></And><And><Eq><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Eq><Eq><FieldRef Name="User_x0020_Support_x0020_Deliver" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Eq></And></Or></Where>]]>
        </property>

----EDIT 6----

ok i replace <eq> with <Contains> , but did not work.

i tried this query, where i only specify the first 32 characters of my site columns internal names . but no results were returned:-

<property name="QueryOverride" type="string" ><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Contains><Contains><FieldRef Name="Technical_x0020_Delivery_x0020_T" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains></And><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Contains><Contains><FieldRef Name="User_x0020_Support_x0020_Deliver" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains></And></Or></Where>]]> </property>

here is i am providing the full column internal names . but also no results were returned:-

<property name="QueryOverride" type="string" ><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Contains><Contains><FieldRef Name="Technical_x0020_Delivery_x0020_Team" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains></And><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Contains><Contains><FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains></And></Or></Where>]]> </property>

here i remove the site columns filtering , but i kept the internal <And> but no results were returned !!:-

    <property name="QueryOverride" type="string" ><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Contains></And><And><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Contains></And></Or></Where>]]> </property>

Finally when remove the site columns filtering & internal <And>, i got results, for all the items within the specified CTs , of course i need to filter based on site columns, but i did this as a test:-

    <property name="QueryOverride" type="string" ><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions Technical Delivery Risk Issue</Value></Contains><Contains><FieldRef Name="ContentType"/><Value Type="Computed">Business Functions User Support Delivery Risk Issue</Value></Contains></Or></Where>]]> </property>

so can you advice why my first three queries did not return any results, while the fourth did a basic filtering ?

Also when i tried only referencing the site columns without the CTs using their GUID instead if their internal names, as follow , i did nto get any results also:-

<property name="QueryOverride" type="string" ><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE" /></OrderBy><Where><Or><Contains><FieldRef ID="{68bd4d83-dbfa-4e0a-af37-76c0a0056ae8}" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains><Contains><FieldRef ID="{3d0722a8-5b0f-4027-b926-2d3e730ce80a}" LookupId="TRUE" /><Value Type="Lookup"><UserID /></Value></Contains></Or></Where>]]></property>  

so i think the problem is related to not being able to get the login user using the above markup ... but still no results will be returned ..

--- EDIT 7 -----

I read this article which talks about similar problem i am facing:-

http://developeratwar.com/2012/12/querying-for-current-users-items-using-the-content-by-query-web-parts-queryoverride-property/

so seems when writing CAML inside CQWP i need to define the login user as follow:-

 <Value Type='User'>
          <UserID/>
        </Value>

so i modified my CAML query as follow. mainly to return all items that have "status = "closed" AND (sitecolumn1 = login user OR sitecolumn2 = login user)":-

<property name="QueryOverride" type="string"><![CDATA[<OrderBy><FieldRef Name="Created" Ascending="FALSE"/></OrderBy><Where><And><Eq><FieldRef Name="Risk_x002F_Issue_x0020_status"/><Value Type="Choice">Closed</Value></Eq><Or><Eq><FieldRef ID="{6937ba16-d8e1-4f57-b86f-232c4d193aa0}"/><Value Type="User"><UserID/></Value></Eq><Eq><FieldRef ID="{ac6b3e79-81af-477d-bf51-a9e3942bac6d}"/><Value Type="User"><UserID/></Value></Eq></Or></And></Where>]]></property>  

now this is the first time i start receiving results,, but i am facing a strange problem is that any item that is closed and assigned to the login user will be returned ,even if the above 2 site columns is not assigned to the user .. so not sure how this CAML query has been translated.. for example if i have a list item with column id {123456789ABC...} =login user & status = closed ; it will be returned, even if the 2 site columns i am filtering based on inside the CAML are null ..so can you advice , why i am getting this ?

4
  • Have you tried using content search webpart instead?
    – HarryB
    Nov 18, 2015 at 10:36
  • @HarryB i would try it , but only if it is not supported by the Content Querty web part ,, till now i can not determine what is wrong ?
    – John John
    Nov 18, 2015 at 13:46
  • Have you looked in the ULS logs to check if your query is finding no matches or sharepoint is throwing some error behind the scenes? it is worth investigating the ULS logs
    – HarryB
    Nov 18, 2015 at 14:36
  • @HarryB i really gave up it took me 5 days to figure out what is going on and nothing is working well. Now what I am planning to do is to add the 2 site columns which i am filtering on inside the 2 content types , and hide the un-wanted column, in this case the 2 site columns will be available inside the items (one will be shown while the other will be hidden) in this case i can define the filtering using the UI without having to write a CAML query. Also I wrote my problem on MSDN but i did not get any reply,,
    – John John
    Nov 19, 2015 at 0:16

3 Answers 3

3

When you use QueryOverride, you can no longer modify all query related values using a browser. So you will need to fix the query, reupload the webpart, and repeat those two until you have a working web part.

Use the internal Field name, yours look like the display name which won't work.

For Content Type filtering, best is to use ContentTypeId.

<FieldRef Name='ContentTypeId' />
<Value Type='ContentTypeId'>YourContentTypeIdHere</Value>

Note that long field names are truncated to 32 chars, at least in my environment the fields named "Technical Delivery Risk/Issue Owner" and "User Support Delivery Risk/Issue Owner" ended up being like this on the list:

<FieldRef Name="Technical_x0020_Delivery_x0020_R" />
<FieldRef Name="User_x0020_Support_x0020_Deliver" />

Also User lookup needs to be of type Lookup.

So basically this will work, including the "In Progress", just constructed list in my system and tested it:

<Where>
  <Or>
    <And>
      <Eq>
        <FieldRef Name="Status" /> 
        <Value Type="Choice">In Progress</Value>
      </Eq>
      <And>
        <Eq>
          <FieldRef Name="ContentType" /> 
          <Value Type="Computed">ContentTypeTwo</Value>
        </Eq>
        <Eq>
          <FieldRef Name="Technical_x0020_Delivery_x0020_R" LookupId="TRUE" />
          <Value Type="Lookup"><UserID /></Value>
        </Eq>
      </And>
    </And>
    <And>
      <Eq>
        <FieldRef Name="Status" /> 
        <Value Type="Choice">In Progress</Value>
      </Eq>
      <And>
        <Eq>
          <FieldRef Name="ContentType" /> 
          <Value Type="Computed">ContentTypeOne</Value>
        </Eq>
        <Eq>
          <FieldRef Name="User_x0020_Support_x0020_Deliver" LookupId="TRUE" />
          <Value Type="Lookup"><UserID /></Value>
        </Eq>
      </And>
    </And>
  </Or>
</Where>
1
1

I had a quite similar problem: CQWP with a custom query (because the item type I had to use for the CQWP didn't allow me to use one of the columns I wanted to query) showing no results but the same error message. It tooke me quite some time to make it work.

It seems to me the problem was that the column I wanted to use wasn't part of the "CommonViewFields"-Property of the webpart file at the right time (I did add it as well as the custom query in one single edit and then tried to import it and publish it - resulting in the same error message you're currently facing).

Try following:

  • Add a clean CQWP and make your basic Settings
  • Export the CQWP and edit it - just add the custom column you want to use to the "CommonViewFields"-Property
  • Import the webpart and publish it (and maybe check for any problems)
  • Export the webpart once more - this time you add your custom query to the webpart file
  • Import the Webpart (it should work at this point now)

This approach did work for me, finally (meaning the wabpart shows the result I want to see - though the error message still remains when I want to edit the webpart using the browser). I can only guess for why this approach might work.

I hope this helps!

6
  • can you please check Edit-4 section of my original question i added the fields to the CommonViewFields but still no results are being returned ..
    – John John
    Nov 18, 2015 at 13:44
  • can you adivce further please ?
    – John John
    Nov 19, 2015 at 0:19
  • Did you make sure to add the CustomViewFields before adding QueryOverride? In my case, I had to add the CustomViewFields, then import the modified CQWP, then export this modified CQWP again, then add the QueryOverride and import it again.
    – Alex
    Nov 19, 2015 at 7:39
  • yes i did this ,, i describe the full details of what i did inside "Edit 5 "section inside my original question .. thanks
    – John John
    Nov 19, 2015 at 12:26
  • can you adivce more on this please if you can ?
    – John John
    Nov 19, 2015 at 17:31
1

In the edit where the error is gone but there are no results:

You are using an exact match for user name, the login name is made somewhat cryptic with the domain prefixed. Try using contains instead of equals and I'm sure it will start returning results. It was the same case when we filter items on Current user in Dataview webpart.

Also you can try replacing <Eq> with <Contains> for both ContentTypeId field in QueryOverride property

2
  • appreciate your reply, but using <Contains> instead of <Eq> did not solve the problem. can u please check my "Edit 6" section where i provided 4 samples of the CAML queries i tried ,,,3 of them failed , while one simple query return results
    – John John
    Nov 20, 2015 at 12:29
  • seems when writing CAML inside CQWP i need to define the login user as follow:- " <Value Type='User'> <UserID/> </Value>" .. so can you check my Edit-7 section pelase ?
    – John John
    Nov 20, 2015 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.