Dear Experts,
I am doing a Bulk upload of Documents and I want a default approval workflow on the document Library to gets disabled but not removed so that mails wont go to respective group for Approval. Also the Uploaded documents should get auto approved without firing email
I tried the following
Solution 1
SPSite siteColl = item.ParentList.ParentWeb.Site; SPWeb site = item.ParentList.ParentWeb; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) { using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID)) { ElevatedSite.AllowUnsafeUpdates = true; Hashtable data = new Hashtable(); data[SPBuiltInFieldId.Completed] = "TRUE"; data[SPBuiltInFieldId.PercentComplete] = 1; data["Formdata"] = SPWorkflowStatus.Completed; data[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)item.Web.Language), "WorkflowTaskStatusComplete", new object[0]); data[SPBuiltInFieldId.Completed] = "TRUE"; bool suceed = SPWorkflowTask.AlterTask(item, data, true); ElevatedSite.Update(); ElevatedSite.AllowUnsafeUpdates = false; } } });
Solution 2
foreach (SPWorkflowAssociation Association in spDocLib.WorkflowAssociations) { Association.Enabled = false; spDocLib.Update(); spWeb.Update(); }
Both the solutions were not working for me. Solution 1 throwing an error stating that the method doesnt exist at
SPWorkflowTask.AlterTask(item, data, true);
I am stuck with this for quite some time. Please help