Tag Info

New answers tagged


I think it would be easier to create a workflow that "Flags a document for removal". Your workflow could: Update a status column to 'pending deletion' Issue a task/email to an approver to approve the deletion If approved, the document would be deleted If not, the status would change to 'rejected' In the default view for the library, you should only ...


I ended up just parsing the "LikedBy" column as the last user would be the one who most recently liked the item. var split = listItem["LikedBy"].Split(";#".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (var i = split.Length - 1; i >= 0; i--) { int userId; if (int.TryParse(split[i], out userId)) return userId; } return 0;


First, if this is your real production code, you should really consider adding error handling with at least a try/catch blog and log the error to the SharePoint ULS log. Second, your code fails because it assumes that the feature activation happens while on a particular SharePoint web site: SPSite site = properties.Feature.Parent as SPSite; If activating ...


As, suggested by Shailen, get the user's Id and update the author field. Check the sequence of 'EventFiringEnabled' to make sure your code is running after SP's. item[SPBuiltInFieldId.Author] = userId; item.SystemUpdate(false); Also, make sure you're wrapping your code inside SPSecurity.RunWithElevatedPrivileges(delegate() { ... });


Have you tried properties.CurrentUserId and explicity pass that to the Created property of the new listitem ?

Top 50 recent answers are included