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

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>
share|improve this question

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer

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.

share|improve this answer
    
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

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)

share|improve this answer

Your Answer

 
discard

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