Getting Work flow Status of Custom Workflow in SharePoint 2010
lstImplItem.Workflows[0].IsCompleted; ---> this single line gives the whether the workflow is completed are not it gives only completed status, if you want to use canelled, inprogress it dosent work below one is the best
There is nothing changes you just Keep Your WorkFlow Name to that string Workflow name.. no changes...
protected string GetWorkflowStatus(SPListItem itm)
{
string workflowName = "Multiple Tasks Workflow"; //name of the workflow you have pass
string statusText = string.Empty;
try
{
SPWorkflowManager manager = itm.Web.Site.WorkflowManager;
foreach (SPWorkflow instance in manager.GetItemWorkflows(itm))
{
if (instance.ParentAssociation.Name == workflowName)
{
foreach (SPField field in instance.ParentList.Fields)
{
if (field is SPFieldWorkflowStatus)
{
SPFieldWorkflowStatus statusField = (SPFieldWorkflowStatus)field;
if (statusField.Title == workflowName)
{
if (itm[statusField.StaticName] != null)
{
int statusValue = int.Parse(itm[statusField.StaticName].ToString());
statusText = statusField.GetFieldValueAsHtml(statusValue);
fieldName = statusField.StaticName;
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
}
return statusText;
}
Comments