Forum Discussion
SharePoint Workflows: Extend Timeout
- Jun 05, 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.
I went through and looked at this yesterday. I am struggling with a few things.
The example doesn't have any CS files so I am unable to following in the code.
Our workflow is fully from Visual Studio so we don't use SharePoint designer for much.
I have also looked at the following link...
https://roykim.ca/2013/08/17/sharepoint-2013-workflow-integration-with-the-waitforcustomevent-activity/
I was able to create 'Workflow Custom Activity' and add a wait action; however, I was unable to determine how to call from Visual Studio or integrate with my existing SharePoint workflow in Visual Studio. I was able to determine that though the following is provided...
stsadm -o setproperty -pn workflow-eventdelivery-timeout -pv "30"
It's not honored. I changed the value to 60 and it only allowed the WF to run for about 20 minutes.
I am currently thinking that I need to create a 'Workflow Custom Activity' but I don't see how to tie it to my existing workflows. If I can't, and it's something I call from my client that's fine. However, that will result in some hefty code changes. Currently trying to just create the 'Workflow Custom Activity' place the WaitEvent on it and then call and see if it hits the break points I desire.
SharePoint 2013 or SharePoint 2016 Workflows are declarative but you can make web service calls from these workflows to execute the code.
You need to double-click on each state in the workflow to know more it. This app user association form. I am adding few screenshots for your reference.
Here you can see how the delay activity was added. The last screenshot you can see how the HTTP activity used to make a call to external web service.
You can create a custom workflow activity using visual studio and it will be available automatically in the toolbox as part of the solution. Please let me know if you still have questions. Thanks.
- Craig LambJun 11, 2018Copper Contributor
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.
- Prasad PunneriJun 12, 2018Brass Contributor
As far as i know from your WF picture, its a sequential workflow you wanna execute.
and the one Devendra is suggesting about the SP 2013 based WF engine that doesnt have any C# code.
its purely declarative. so, the WF you have created is will generate a WSP,along with DLL and deploy the wsp onto your solution store. This is the traditional approach we followed till the advent of SP 2013.
So, you can use any activity that's applicable in MOSS 2007 WF, SP 2010 WF Visual studio workflows.
Either you can use sequential or state machin WF.
SPWorkflowAssociation , SPQurey are the object thats used extensively in SSOM(Server Side Object Model).
But do not mix this with the SP 2013 declarative WF. if you try this type of combining a declarative SP 2013 WF with the old SP 2010/ MOSS 2007 Sequential WF /State machine , then it will fail.
The workflow you have created will work only in the ON-PREM environment. you cant execute code against a SPO site.
- Craig LambJun 12, 2018Copper ContributorThank you soooo much. This helps and is getting me more on track.
So, I just need to add a Listen and move the code into there?
- Craig LambJun 12, 2018Copper ContributorAlso... I can't do anything in Azure since the projects we support are government. They frown against the cloud. :(