Recently, I was getting this error when non-admin were trying to alter a workflow task. My code was running under elevated permission using the option first as described in my last post(using SharePoint\System) user
To fix, I need to run the code under elevated permission using second option as described in my last post(RunWithElevatedPrivileges)
string siteURL = SPContext.Current.Site.Url;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite objSite = new SPSite(siteURL);
SPWeb web= objSite.OpenWeb();
web.AllowUnsafeUpdates = true;
Hashtable taskHash = new Hashtable();
SPListItem item = null;
item["Status"] = "Completed";
SPWorkflowTask.AlterTask(item, taskHash, false);
web.AllowUnsafeUpdates = false;
});
1 comments:
Hi Sanjay,
I must say that your article and information is very good and useful.
You save my lots of debugging time, thank you very much!!
Thanks,
Sanket Shah
Post a Comment