In this tutorial, I will show you how toCheck Logged in User is belong to any Type. In SharePoint List every column has internal name. some time column name & its internal name is different.
Created By column – internal name -> Author.
Modified By column – Internal Name -> Editor.
ContactDetails list contains column “AllUser” type -> Person or group (Allow Multiple selection = true).
Write the following code to fetch list records wherever current user has created list items or changed list items or it belong to “AllUser” group.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
List oList = clientContext.Web.Lists.GetByTitle("ContactDetails"); CamlQuery camlQuery = CamlQuery.CreateAllItemsQuery(); string UserTilte = "Rupali Shinde"; string QueryStr = ""; //Created By - Internal Name -> Author //Modified By - Internal Name -> Editor //Check loggedIn User is belog to any of 3 type - Author/Editor/AllUser(user defined column). QueryStr = @"<View>" + "<Query>" + "<Where>"+ "<Or>" + "<Eq>" + "<FieldRef Name='Author'/>" + "<Value Type='User'>" + UserTilte + "</Value>" + "</Eq>"+ "<Or> " + "<Contains>" + "<FieldRef Name='AllUser'/>" + "<Value Type='UserMulti'>" + UserTilte + "</Value>" + "</Contains>" + "<Eq>" + "<FieldRef Name='Editor'/>" + "<Value Type='User'>" + UserTilte + "</Value>" + "</Eq>"+ "</Or>" + "</Or>" + "</Where>" + "</Query>" + "</View>"; camlQuery.ViewXml = string.Format(QueryStr); Microsoft.SharePoint.Client.ListItemCollection collListItem = oList.GetItems(camlQuery); clientContext.Load(collListItem); clientContext.ExecuteQuery(); int itemcount = collListItem.Count; |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.