Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am facing a little problem in how to use CAML query in my code.

My scenario is as a user logs in the site check that particular user for his permissions on site and then display all the list items created by him or tasks created by him in a tabular form with a count of tasks for every month.

I am not able to understand how to integrate or use both the permission check and display list items together for the logged in user so that other users data is not visible to him.

Can any one guide me in this or direct me to a well structured code wherein i can get a reference.

I am novice in this and having a tough time in understanding how it all works.

Thanking in advance
Posted

1 solution

You have no need to worry about the permission of the user on the list to be queried because SharePoint will return the results based on the user permission on the list.

For returning only the items created by the current logged in user you can use the following CAML query

C#
"<Where>
 <Eq>
  <FieldRef Name="Author" LookupId="TRUE" />
  <Value Type="Integer">" + SPContext.Current.Web.CurrentUser.ID + @"</Value>
 </Eq>
</Where>"
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900