1

I am trying to hard code a user group into a CAML query's where clause. The reason is so that I can apply additional criteria when the user is in one group, and something else if they are in another group. I don't want to check the "Assigned To" field for a value, I just want to hard code a user group in it. How do I do that? Thank you. Here is the CAML :

<Query>
                <Where>
                    <Membership Type="CurrentUserGroups">
                      <FieldRef Name="AssignedTo"/>
                    </Membership>
                </Where>
                <GroupBy Collapse="FALSE">
                    <FieldRef Name="AssignedTo"/>
                </GroupBy>
                <OrderBy>
                    <FieldRef Name="AssignedTo"/>
                    <FieldRef Name="Status"/>
                    <FieldRef Name="Priority"/>
                </OrderBy>
            </Query>
1

Another solution is to add another people or group field in the list and populate it with a workflow. Then, use that field in between the membership type elements instead of "AssignedTo".

0

This is a long shot but try just entering the name of the group in between the Membership tags. You may need to format it with the group ID, then ;# and finally the group name.

1
  • Thank you Alex. I tried 14;#Division_x0020_Managers in between the membership tags but wasn't successful. – Anonymous Jul 5 '10 at 17:10
0

Unfortunately you can't combine Membership element with Value element. See syntax (childs element) documentation of Membership element.

<Membership Type="CurrentUserGroups">
  <Value>NOT POSSIBLE</Value>
</Membership>

If you use SP Server you can use feature: Audience targeting settings

  1. Create more Views, where every view is for specific group.
  2. Show each view to diferent group: Add all views to Page (use add WebPart) and set webpart property in advance tab Target Audiences(in c#: AuthorizationFilter). To this property you can add specific group name. WebPart is shown only to this group.

In SP Foundation you can't use this. But you can implement your own WebPart RuntimeFilter. More info about RuntimeFilter is in book SharePoint 2010 Web Parts in Action (page 140-147)

Your Answer

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