Pergunta

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>
Foi útil?

Solução

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

Outras dicas

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.

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)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top