1

I'm trying to get "AutoCleaupDays" property of workflow association but workflowassociation always returning null. Then I tried with workflowSubscriptionService & here I am getting my workflow but it does not expose "AutoCleaupDays" property. below is my code

CODE 1: Using SPList.WorkflowAssociations

SPList list = web.Lists.TryGetList("IT-Request-Form");
SPWorkflowAssociationCollection WAC = list.WorkflowAssociations;//Its returing null
System.Globalization.CultureInfo culinfo = new System.Globalization.CultureInfo("en-us");
SPWorkflowAssociation WA = WAC.GetAssociationByName("WorkflowAssociation_5fb922d2693c4b718c652ce7d5eb49ce", culinfo);
int days = WA.AutoCleanupDays;

SPWorkflowAssociationCollection returning null.

CODE 2: Using GetWorkflowSubscriptionService

var workflowServiceManager = new WorkflowServicesManager(web);
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(list.ID);
foreach (var workflowSubscription in subscriptions)
{
 //here i get "Object reference not set to an instance of an object" exception
 string autoCleanupDays = workflowSubscription.GetProperty("AutoCleanupDays").ToString();

 //Then i checked Properties & allProperties does not contains "AutoCleanupDays" Property
 ICollection<string> allProperties  = workflowSubscription.PropertyDefinitions.Keys;

}

So how I get "AutoCleaupDays" value of workflow in SP2013?

1 Answer 1

0

I replied your post: Does Completed workflow instances automatically cleaned up after 30 days in sharepoint 2013?

I provided how to set AutoCleanupDays property using PowerShell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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