How to Initiate / Start a K2 Workflow from a non-SmartForm or non-SharePoint event?

  • 11 September 2015
  • 4 replies
  • 10 views

Badge +2

 

Hi all,

 

I've read about the standard ways to start a K2 Workflow:  When a SmartForm is submitted, or when a SharePoint (or InfoPath, I think) event occurs.  However... 

 

We're implementing a Scanning/ECM solution using K2 and would like to trigger/Start a K2 Workflow when a "different" (non-SmartForm, non-Sharepoint) event occurs, such as a scan file gets dropped into a watched folder.  Something like that.

 

Is there any way to do this?  I've looked online, in the K2 documentation, and the Community, but have come up short, except possibly for some reference to creating a Windows Service using the K2 Object Model to start a workflow (?), OR using the Client API (neither of which I have any experience with).

 

Thanks in advance!

 

Bruce Rodgers

RhinoDox, Inc.


4 replies

Userlevel 1
Badge +8

Hi Bruce

 

For your reqirements you will need to build a custom solution to trigger the K2 workflow. There are 2 basic ways you can start a workflow, from the Client API  or via a web service (WCF, REST). In either case it is going to require some level of custom coding to achieve as you will need to programatically watch your folder for changes and then start the workflow. A windows service would be a good candidate for this.

 

Have a look at the K2 developer reference for further details:

 

Workflow Runtime APIs and Services

 

How to set data fields and start an instance of a process

 

Starting workflow with the SOAP WCF service

Badge +2

Good on ya, Andrew - thanks for the the quick reply!

 

You said:

"For your reqirements you will need to build a custom solution to trigger the K2 workflow. There are 2 basic ways you can start a workflow, from the Client API  or via a web service (WCF, REST). In either case it is going to require some level of custom coding to achieve as you will need to programatically watch your folder for changes and then start the workflow. A windows service would be a good candidate for this."

 

So, you're saying that I need to write a Windows Service to monitor the "watch" folder (I figure this was the way to go), and when a file is written (or whatever), from the Service I can then start the K2 workflow using either calls to the K2 Client API, or calls to the K2 WCF Web Service?

 

I'm sure it depends on the application, but is one recommended more than the other?   The "Workflow Runtime APIs and Services" link you sent does have a nice comparison chart of the different technologies, but just looking for any advice.  Been a while since I've done this stuff, and we have an aggressive schedule. :)

 

Cheers,

Bruce

 

 

 

Userlevel 1
Badge +8

Hi Bruce

 

I don't really have a recommendation except to say use whatever you are most comfortable with. If you are not familiar with web services then the Client API is probably easier to understand and implement.

Badge +10

Hi Bruce,

 

You can also look at building a custom Event Recorder.

The example in the Developer Reference is actually implementing a folder monitoring solution.

See it here: http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.10/default.htm#Extending_ThirdPartyEventRecorder.html

 

Hope this helps!

Regards,

JohanL

Reply