Hot answers tagged

3

You could optimize the code by getting all the items that you need before the for loop, instead of requesting every item and going to the server to get it from within the loop. So, basically, you need to create a query object, get all items in one call to the server, and then loop through items and do whatever you need to do. This way you will save both the ...


2

In the absence of a better answer, I am inspecting the value of the _VirusStatus field. If the file has been scanned it will have a value in this field. Possible values (from the MS documentation): case "0": // No Virus detected case "1": // Virus reported by the scanner plugin but not yet determined if removal possible. case "2": // Virus reported by ...


1

I had same requirement and here is what i did, First, get ID of last modified item from the list. ClientContext clientContext = new ClientContext("your site"); Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("TestList"); clientContext.Load(spList); clientContext.ExecuteQuery(); if (spList != null && spList....


1

I would suggest that first find the internal name of the column and then use that. You can find the internal name of any Felds using C# code as well. This is shown here


1

To register a site as Hubsite, you can use the below code: string tenantAdminSiteUrl = "https://tenant-admin.sharepoint.com/"; string userName = "admin@tenant.onmicrosoft.com"; string password = "password"; using (ClientContext context = new ClientContext(tenantAdminSiteUrl)) { SecureString securePassword = new SecureString(); foreach (char c ...


1

You cannot grant a permission on a file before uploading it as there is nothing to set the permission on before the file has been uploaded, unless you have a container (folder). In any case, if you upload the file and then set the permission, the file would only be visible for a second or so, and probably just a fraction of a second. If you use folders, you ...


1

Interesting use case, I am not sure if we are able to update via REST API but with CSOM you definitely can update Below Below is using Powershell CSOM, but same can be used in C# or Javascript object model. function Change-WebPart { #variables that needs to be set before starting the script $siteURL = "https://spfire.sharepoint.com" $userName =...


Only top voted, non community-wiki answers of a minimum length are eligible