New answers tagged

0

You need to remove the user's permissions on the file then give the user Read-Only permission on the file. Here is my demo for you: using (SPWeb web = site.OpenWeb()) { SPFolder documentSet = web.GetFolder("http://sp2016/sites/dev/Shared%20Documents/DocumentSet"); SPPrincipal user = web.EnsureUser("contoso2016\\...


0

You can use workflows to do this job or in an eventHandler, remove Delete and edit permissions on this item item.RoleAssignments.Remove(....)


0

I have the same problem and found below fix: var userLogin = properties.AfterProperties["UserField"].ToString(); var userFieldValue = new SPFieldUserValue(web, userLogin); var user = web.EnsureUser(userFieldValue.LookupValue);


1

Sample test demo for you reference: public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); SPListItem item = properties.ListItem; using (SPWeb web = properties.OpenWeb()) { SPQuery query = new SPQuery(); string username = new SPFieldUserValue(...


0

Sample code for your reference. public override void ItemAdding(SPItemEventProperties properties) { using (SPWeb oWeb = properties.OpenWeb()) { SPList oList = oWeb.Lists.TryGetList("listB"); SPListItem item = oList.GetItemById(2); object color = item["Color"...


Top 50 recent answers are included