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:
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:-
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 ?