Sharepoint 2010 List View trouble: doesn't work CAML query for group selection

1.2k Views Asked by At

I've created a "By my group" view in Schema.xml for a TaskList, using best known solution:

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

However, It doesn't work for me... Possible reason: I'm using FBA authentication with tokens (I've noticed, that after login

SPFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(securityToken);

User disappeared from SharePoint group). But! I checked next query:

string camlquery = 
"<Where>
      <Eq>
          <FieldRef Name=\"AssignedTo\" />
          <Value Type=\"Text\">" + SPContext.Current.Web.CurrentUser.Groups[0].Name+ "</Value>
      </Eq>
</Where>";

And it worked!

The problem is that i can't insert

SPContext.Current.Web.CurrentUser.Groups[0].Name

into the Schema.xml markup

Any ideas about presenting TaskList View for corresponding UserGroup ?

1

There are 1 best solutions below

0
On

Sorry, My fault. The problem was in custom Membership Provider. It was a little bit mixed up (Authentication in Membership used CardId as a login, and in SharePoint login was like a Name+Surname). That's why <Membership Type="CurrentUserGroups"> had no UserGroups, cause it was corresponding user with Login 'CardId' while in SharePoint groups where assigned to users with login Name+Surname.

First Question on stackoverflow failed ^_^.