You are viewing limited content. For full access, please sign in.

Question

Question

Terminate previous workflows running on an instance

asked on February 23, 2014

Hi all,

I have a question.

 

Sometimes users re-run certain workflows on the same instance. I end up with the same workflow running 2 or three times on the same instance.

Is there any way to automatically setup to terminate any previous workflow running on current instance, once current workflow starts running.

I am aware that the activity END WORKFLOW can terminate current or parent workflow, which is the workflow that called the current workflow.

What would happen if a user re-runs the workflow. This option would not work.

Is there a workaround for this?

 

Thanks in advance,

 

Andres

1 0

Replies

replied on February 23, 2014

I don't know of a way to do this with normal workflow activities (and I don't know if this could be done in script).

 

But one thing I do in cases like this where I know a workflow has a chance to have been implemented more than once it to always build a checkpoint after any delays or escalations before it actually implements the subsequent steps to see if I actually still need to. For example if I have an escalation after X time, I check to see if the document is still in the "waiting for X folder". If it's not in the correct place I end the workflow as another process has taken care of it. 

Incidentally this is why I  like making workflows like this into Business Processes so that I can make a record as to why workflow did or did not do something with a document.

2 0
replied on February 24, 2014 Show version history

It is possible but its a bit performance heavy. If you can implement Chris's suggestion I'd recommend that.

 

Please see this older forum post

 

https://support.laserfiche.com/ForumsFrames.aspx?Link=viewtopic.php%3fp%3d69993%26amp%3bhighlight%3d%26amp#69993

 

From that post you'll see:

 

using System; 
 using System.Collections.Generic; 
 using System.ComponentModel; 
 using System.Data; 
 using System.Drawing; 
 using System.Linq; 
 using System.Text; 
 using System.Windows.Forms; 


 using Laserfiche.Workflow; 
 using Laserfiche.Workflow.Objects; 

 using Laserfiche.Workflow.Objects.Instances; 

 namespace Sample 
 { 
     public partial class Class1 
     { 
         private void ChannelTheFlow() 
         { 
             using (WorkflowConnection connection = WorkflowConnection.CreateConnection("Workflow Server Name", "Sample")) 
             {                  
                 SearchFilterOptions options = new SearchFilterOptions(); 
                 options.Statuses = new SearchFilterOptions.WorkflowStatus[] { SearchFilterOptions.WorkflowStatus.Running }; 

                 options.MinEntryId = 1;  // Fill in your entry id here 
                 options.MaxEntryId = 1;   // or The entry id for this workflow is: this.StartingEntryInfo.Id. Set it to both the min and max
                 options.WorkflowName = this.WorkflowApi.WorkflowName; // Or hardcode the name you care about here. If you don't care about the workflow name, then disregard this.

                 foreach (SearchResult result in connection.Database.Tracking.SearchWorkflowInstances(options)) 
                 { 
                     WorkflowInstance instance = result.WorkflowInstance; 
                     instance.Terminate("Termination reason"); 
                 } 
             } 
         } 
     } 
 } 

You also need to reference Laserfiche.Workflow.ServerObjects.dll from the .Net 4 GAC (typically: C:\Windows\Microsoft.NET\assembly\GAC_MSIL

1 0
replied on February 24, 2014

Hi Chris/Ed,

many thanks for your answers. I will try with both options.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.