2

I am trying to iterate, all the workflow instances belonging to the particular listItem in a custom activity for SharePoint 2013 visual studio custom workflow.

WorkflowServicesManager workflowServiceManager  = new WorkflowServicesManager(ctx,oWeb);

var workflowInstancesService = workflowServiceManager.GetWorkflowInstanceService();

var workflowInstances = workflowInstancesService.EnumerateInstancesForListItem(listIDGUID,itemID));

foreach (var instances in workflowInstances)
{
    instances.   -- pls refer the images. 
}

There seems to be no property for the workflow Title/Name.

enter image description here enter image description here

0

Try using the Properties property.

foreach (var instance in workflowInstances)
{
    var properties = instance.Properties;
}

I've never done this before, so to find what properties will be returned for each instance, place a break point on this line and debug. I'm sure you'll find a title/name property there. Then to use it you would do:

var propertyValue = properties["property_name"];

MSDN reference here.

0

A completely different approach you could try:

var list = oWeb.Lists.GetList(listIDGUID, true);
var item = list.GetItemById(itemID);

foreach (var workflow in item.Workflows)
{
    var workflowName = workflow.ParentAssociation.Name;
}
0

You can get that name from WorkflowSubscriptionService. This is how you get that.

    /// <summary>
    /// get workflow name from instance
    /// </summary>
    /// <param name="instance"></param>
    /// <returns></returns>
    public string GetWorkflowName(WorkflowInstance instance)
    {
        var workflowSubscription = WorkflowServicesManager.Current.GetWorkflowSubscriptionService().
                GetSubscription(instance.WorkflowSubscriptionId);
        return workflowSubscription.Name;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.