1

I want to define a query to return items that satisfy the following :-

  1. if any item have a CT & login user = site column

so i wrote the following :-

<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. i wrote this query inside a content query web part .. under the QueryOverride tag and i am providing the CT id +site columns internal names..

EDIt

Now i tried this :-

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

I can confirm that the site column names are the internal names + the content Types ids are correct...

EDIT-2

now i manage to get the CAML tool working , so i wrote the query as follow (i define to use the SP object model):-

enter image description here

but the result will be empty. as i said i am providing the correct site columns internal names, and the content type ids, so can anyone adivce why i am not getting any results ? and i did not see any exception at the same time ..

Thanks

  • 1
    you haven't mentioned User name's value anywhere in query. <FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" /> <Value Type="Integer"><UserID Type="Integer" />[UserValue]</Value> Replace [UserValue] with the ID of user. – Gaurravs Nov 12 '15 at 15:44
  • @Gaurravs now i do not want to specify certain user id , instead i want to get the login user ,, so should i write [Me] ? or it will not work ? – john Gu Nov 12 '15 at 15:51
  • Not sure if it will work, you have to pass logged in user's name using jquery – Gaurravs Nov 12 '15 at 15:54
  • @Gaurravs based on the below answer using "<UserID /> tag " will do this for me .. – john Gu Nov 12 '15 at 16:03
  • refer this blog for how to write such type of query blog.riccardocelesti.it/… – Gaurravs Nov 12 '15 at 16:21
2

Update your query to get the user field values like this:

 <FieldRef Name="User_x0020_Support_x0020_Delivery_x0020_Team" LookupId="TRUE" />
    <Value Type="Integer"><UserID /></Value>
  • but how i can match it to be equal to the current login user ? – john Gu Nov 12 '15 at 15:55
  • 1
    <UserID /> tag does that for you. – HarryB Nov 12 '15 at 15:55
  • ok i modifed my query as you mentioned but no results will be returned,, i also replace the CT ids with the content type display name,, but still no results will be returned .. can u advice ? – john Gu Nov 12 '15 at 16:02
  • Ok. I suggest that you test your query using this tool on codeplex. spcamlqueryhelper.codeplex.com – HarryB Nov 12 '15 at 16:10
  • ok i will try this ,, but what could be causing this ? – john Gu Nov 12 '15 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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