Forum Discussion

rautchetan27's avatar
rautchetan27
Copper Contributor
Jul 10, 2020

CAML query with OR condition

I have following CAML query to filter list items on the basis of Sharepoint group of users.

it allow only display list items which have value in Column Vendor equal to Sharepoint group name of user.

 

<Where><Membership Type="CurrentUserGroups"><FieldRef Name="Vendor" /></Membership></Where>

 

what i want, for particular user(X1234) i want to show all list items.

 


<Where><Or><Membership Type="CurrentUserGroups"><FieldRef Name="Vendor" /></Membership>

<Eq><UserId Type="Text"><Value Type="text">X1234</Value></Eq></Or>

</Where>

 

but its not working, whats wrong with this query?

2 Replies

  • Sudharsan K's avatar
    Sudharsan K
    Steel Contributor

    rautchetan27 

    Try to use the below

    <Where>
        <Or>
            <Membership Type='CurrentUserGroups'>
                <FieldRef Name='Vendor' />
            </Membership>
            <Eq>
                <FieldRef Name='Vendor' />
                <Value Type='Text'>X1234</Value>
            </Eq>
        </Or>
    </Where>
    • rautchetan27's avatar
      rautchetan27
      Copper Contributor

      Sudharsan K 

       

      I dont want to compare field/column, what i want if User is X1234 , it should show all items, no filter apply on the basis of membership thats why i want to use <OR>

Resources