Forum Discussion
SharePoint Workflows: Extend Timeout
- Jun 06, 2018
Craig Lamb SharePoint 2016 uses new workflow engine. You can check the blog post http://www.andrewconnell.com/blog/publishing-custom-events-to-sharepoint-2013-workflowson how to use Custom Events for Long Running External Processes.
Sorry that I appear so confused. I GREATLY appreciate your desire to help.
Attached is a screenshot of our solution. The current screen represents our Workflow. As you can see, we essentially create the workflow object and then it calls our custom code. All of our workflows are from Visual Studio and are executing C# objects that we have created through this path. None are via SharePoint Designer. Our custom code block executes; however, through the workflow container it times out in 20 minutes or so. As you can see, I added an Activities folder under Workflows which is a "Workflow Custom Activity". The questions that I have are the following.
1. I see the WaitForCustomEvent in the "Workflow Custom Activity".
Do I need to move everything that is in the JEMSWorkerProcess to the NEW "Workflow Custom Activity \ ExecuteActions" and then call it differently from the client? Or, can I call this from the JEMSWorkerProcess.
I am trying to prevent myself from having to redo A LOT or work. The JEMSWorkerProcess implementation works. It just won't allow for long runs greater than 20 minutes. If I could extend that it would be great.
Currently we create the WF with...
// Retrieve sharepoint list item based on Project name / folder name for workflow instantiation
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"RecursiveAll\"";
query.Query = "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" + topFolderStr + "</Value></Eq></Where>";
query.RowLimit = 1;
query.ViewFields = "";
SPListItemCollection items = taskOrderDocList.GetItems(query);
SPListItem item = items[0];
//instantiate JEMSWorkerProcess workflow based on the scenario folder
SPWorkflowAssociation workflowAssociation = taskOrderDocList.WorkflowAssociations.GetAssociationByName(Constants.Workflow.JEMSWORKERPROCESS_UNIQUENAME,
System.Globalization.CultureInfo.CurrentCulture);
//pass in the currentstepID so that the actions can be retreived by sp workflow for the step.
string eventData = string.Format("<initData>" + invokeType.ToString() + "," + taskOrderID.ToString() + "," + scenario.ToString() + "</initData>");
SPWorkflow wf = SPContext.Current.Site.WorkflowManager.StartWorkflow(item, workflowAssociation, eventData, SPWorkflowRunOptions.Asynchronous);
If I have to rewrite everything an move it to a "Workflow Custom Activity" that is a BIG effort and learning curve. So, I am trying to get a pulse on what I am up against.
If I change to a Custom Activity is it going to be something like...
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"RecursiveAll\"";
query.Query = "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" + topFolderStr + "</Value></Eq></Where>";
query.RowLimit = 1;
query.ViewFields = "";
SPListItemCollection items = taskOrderDocList.GetItems(query);
SPListItem item = items[0];
string eventData = string.Format("<initData>" + invokeType.ToString() + "," + taskOrderID.ToString() + "," + scenario.ToString() + "</initData>");
ClientContext ctx = new ClientContext(SPContext.Current.Site.Url);
WorkflowServicesManager workflowServiceManager = new WorkflowServicesManager(ctx, ctx.Web);
var workflowInstanceService = workflowServiceManager.GetWorkflowInstanceService();
var workflowInstances = workflowInstanceService.EnumerateInstancesForListItem(taskOrderDocList.ID, item.ID);
ctx.Load(workflowInstances);
ctx.ExecuteQuery();
workflowInstanceService.PublishCustomEvent(workflowInstances[0], "ProcessActions", eventData);
2. Is there a way to extend the JEMSWorkerProcess execution that is just a "Workflow" instead of a "Workflow Custom Activity"?
All I really want is the easiest way for my custom code in JEMSWorkerProcess to run longer, and for me to have total control over that length.