Hi
I have a sequential workflow which is associated to a listwhich contains column name Business Process which could be Purchase Order, Sales, Leave Request etc
I have another list 'Approvers' which contains two columns Group Name & Approvers
eg: Purchase Order Approver1, Approver2
Sales Approver1, Approver2, Approver3
I have created the workflow for the list, but I am not getting an idea as to how to get and loop through the approvers based on the list value.
The following is my code
namespace wfmaintenance.Workflow1 { public sealed partial class Workflow1 : SequentialWorkflowActivity { public Workflow1() { InitializeComponent(); } public string Company; public string BusinessProcess; public string ListName; public string WorkflowName; public string WorkflowInitiation; public Guid workflowId = default(System.Guid); public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties(); public SPWorkflowTaskProperties WfTaskProperties = new SPWorkflowTaskProperties(); public SPWorkflowTaskProperties WfTaskBeforeProperties = new SPWorkflowTaskProperties(); public Guid WfApproveTaskId = default(Guid); public int WfApproveTaskItemId; public bool WfApproveComplete = false; private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) { /** Company = workflowProperties.Item["Company"].ToString(); BusinessProcess = workflowProperties.Item["BusinessProcess"].ToString(); ListName = workflowProperties.Item["ListName"].ToString(); WorkflowName = workflowProperties.Item["WorkflowName"].ToString(); WorkflowInitiation = workflowProperties.Item[" WorkflowInitiation"].ToString(); checkApprovalStatus(); **/ } private void notWfTaskApproved(object sender, ConditionalEventArgs e) { e.Result = !WfApproveComplete; } private void createWfTask_MethodInvoking(object sender, EventArgs e) { SPListItem currentItem = workflowProperties.Item; // Set up some of the properties. WfApproveTaskId = Guid.NewGuid(); WfTaskProperties.Title = workflowProperties.Item["ListName"].ToString() + " is ready for review"; WfTaskProperties.Description = "Please review and ensure it is valid. If it is valid, then please select 'Approved' on this task and save it."; } private void onWfTaskChanged_Invoked(object sender, ExternalDataEventArgs e) { //int tid = onWfTaskChanged.AfterProperties.TaskItemId; SPListItem task = workflowProperties.Web.Lists["Workflow Tasks"] .GetItemById(WfApproveTaskItemId); SPListItem currentItem = workflowProperties.Item; try { if (task["Business Approval"] != null) { // Evaluate the value of the field. if (task["Business Approval"].ToString() == "Approved" || task["Business Approval"].ToString() == "Rejected") { WfApproveComplete = true; task[SPBuiltInFieldId.WorkflowVersion] = 1; task["Status"] = "Completed"; task.Update(); } else { WfApproveComplete = false; } } else { WfApproveComplete = false; } } catch (Exception ex) { WfApproveComplete = false; } } private void completeWfTask_MethodInvoking(object sender, EventArgs e) { SPListItem task = workflowProperties.Web.Lists["Workflow Tasks"] .GetItemById(WfApproveTaskItemId); //task[SPBuiltInFieldId.WorkflowVersion] = 1; //task["Status"] = "Completed"; //task.SystemUpdate(false); SPListItem currentItem = workflowProperties.Item; if (task["Business Approval"].ToString() == "Rejected") { string ListName = workflowProperties.Item["ListName"].ToString(); string currentTitle = workflowProperties.Item["Status"].ToString(); workflowProperties.Item["Status"] = ListName + "is Rejected "; workflowProperties.Item.Update(); } else { string ListName = workflowProperties.Item["ListName"].ToString(); string currentTitle = workflowProperties.Item["Status"].ToString(); workflowProperties.Item["Status"] = "is Approved "; workflowProperties.Item.Update(); } } } }
Thanks