Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In a custom list definition, I'm building a view with this query :

      <Where>
          <Or>
            <Membership Type="CurrentUserGroups">
              <FieldRef Name="MyUserField" />
            </Membership>
            <Eq>
              <FieldRef Name="MyUserField" />
              <Value Type="Integer">
                <UserID Type="Integer" />
              </Value>
            </Eq>
          </Or>
      </Where>

As you guessed, the idea is to show only items if the field MyUserField contains the current user or a group where the user is a member.

Now I would like to change my query to restrict the display to users that are not designated (directly or via membership) in a second group.

I don't see any definition nor for a Not operation in Caml, neither for a NotMembership. This is not working :

<Where>
    <And>
        <Or>
            <Membership Type="CurrentUserGroups">
                <FieldRef Name="MyUserField" />
            </Membership>
            <Eq>
                <FieldRef Name="MyUserField" />
                <Value Type="Integer">
                    <UserID Type="Integer" />
                </Value>
            </Eq>
        </Or>
        <Not>
            <Or>
                <Membership Type="CurrentUserGroups">
                    <FieldRef Name="MyUserField2" />
                </Membership>
                <Eq>
                    <FieldRef Name="MyUserField2" />
                    <Value Type="Integer">
                        <UserID Type="Integer" />
                    </Value>
                </Eq>
            </Or>
        </Not>
    </And>
</Where>

Any suggestion?

share|improve this question
add comment

1 Answer

I just ran a query on a list in SP CAML Query Helper and I got results with this:

            <Query>
                <Where>
                    <And>
                        <Membership Type="CurrentUserGroups">
                            <FieldRef Name="AssignedTo"/>
                        </Membership>
                        <Neq>
                            <FieldRef Name="AssignedTo" />
                            <Value Type="Integer">
                                <UserID Type="Integer" />
                            </Value>
                        </Neq>
                    </And>
                </Where>
            </Query>

Using Eq I returned 0 results and using Neq I returned 1 result. This seems to what you are looking for. (Although almost a year late!)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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