New answers tagged

0

The closest thing I can think of is this pseudocode: foreach roleAssignment 'rA' foreach roleDefinitionBinding 'rDb' in rA.get_roleDefinitionBindings() Check if user has the base permissions associated with the contributor role by repeatedly using rDb.has(...) which checks for a base permission if true, delete current roleAssignment from listItem An ...


3

Using SPList.Items property is bad practice. Each time the property is accessed, it requests all items with all fields from database. Instead you should always use SPList.GetItems(). SPList.GetItems(params string[]) - you can use it to load only the fields that you need. As far as I remember it'll only return items in the root folder of the list. SPList....


1

If it is just a case to get all items than I always use DataTable to get allitems using below code & do the operations. static void Main(string[] args) { try { SPWeb oWebsite = SPContext.Current.Web; SPList oList = oWebsite.Lists["Employees"]; SPListItemCollection collListItems = oList.GetItems(); DataTable dt = ...


3

This code should work: (web is a variable that references the web object) SPFieldUserValue value = new SPFieldUserValue(web, item["AssignedTo"].ToString()); if (value) { assignToUser = value.User; }


2

You can try below code to get SPUser in AssignedTo columns for specific item. If(task["Assigned To"] != null) { string fieldValue = Convert.ToString(task["Assigned To"]); SPFieldUserValue assignedTo = (SPFieldUserValue) task.Fields["Assigned To"].GetFieldValue(fieldValue); }


2

Try this SPFieldUserValue userField = item.Fields["AssignedTo"] as SPFieldUser; string userName = item["AssignedTo"].ToString(); SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(userName); SPUser user = fieldValue.User; Taken from http://ethan-deng.blogspot.com/2013/03/get-spuser-from-user-column-there-are.html


2

You can try below code, using (SPSite siteCol = new SPSite("http://server/sites/Contoso")) { using (SPWeb web = siteCol.RootWeb) { SPList list = web.GetList("/sites/Contoso/Lists/Books"); SPListItem item = list.GetItemByIdSelectedFields(3, "Title", "ISBN", "Retail_x0020_Price"); String bookISBN = ...


0

You have to write Javascript on the page and modify the PreSaveAction() functionality. In preSaveAction functionality check in if condition the value of Status Field, If its resolved, set Date column to Today. I can write the script but you will get it easily if you do some googling.


0

It is the Completed column in a Tasks list that is displayed as the Checkbox. If you, instead, see the Yes/No values it means the needed (SharePoint) JavaScript hierarchytaskslist.js was not executed on the ListView. One scenario can be you have attached JSLinks on the WebPart, this prevents execution of any JS files attached to the View definition As seen ...


2

Single line of text can store 255 characters. So you will be good even in case of IPv6. One drawback of storing interger in text field is that you will lose the out of the box ability to apply mathematical functions like SUM etc.


2

Use the below code, it will give you the list of Fields that are in Display in the View and the postiion from left. public static void GetViewDetails() { ClientContext context = new ClientContext("https://testsite/test"); List list = context.Web.Lists.GetByTitle("ListName"); context.Load(list); context....


2

Another Way You can get it using REST API. Just send a GET request to the following end point /_api/Web/Lists/GetByTitle('{list name}')/Views/GetByTitle('{view name }')/ViewFields In the response, you should get response like following { "d": { "__metadata": { "id": "Web/Lists/GetByTitle('Customers')/Views/GetByTitle('All Items')/...


0

All answers are not safe, when the field is null. This can happen, when a field gets later added and already items are in this list. This is a safe cast: bool? showTitle = properties.ListItem["ShowTitle"] as bool?; if (showTitle.HasValue && showTitle.Value) { }


2

You can check the ids from data.$1L_0 with the actual ids from your list. If they are same, then you can rely on data.$1L_0. Anyway following JSOM approach, you can flow: Add items in a array, then get ids from it using get_id(). var itemArray = []; var clientContext = SP.ClientContext.get_current(); var oList = clientContext.get_web().get_lists()....


1

You can use: query.QueryThrottleMode = SPQueryThrottleOption.Override; by executing the query as a super user. SharePoint 2010 List Throtelling Try the following code to get the items based on the folder, using(SPSite site = new SPSite("site url")) { using(SPWeb web = site.OpenWeb()) { SPFolder folder = web.GetFolder("/Docs/folder1"); if(...



Top 50 recent answers are included