Skip to main content

Hi,

I have two questions :

1. How to call K2 Workflow from javascript or client side scripting?

2.How to deploy workflow from one environment (Dev) to other environment(Prod)?

 

 

1. You would have to create a web service or something similar to access via JavaScript.  The web service would then use the K2 API or something similar to kick off a workflow.

 

2. You select the environment to which you wish to deploy during the deployment process.  See attached.


15261iF9E6BB3D1F16F38B.png

Hello  @SACHINFORK2,

 

I am not sure of what you are trying to achieve so I will assume that "call K2 Workflow" means "start a K2 process".

 

First of all, you could do that using a smo and the story would be wrapped up without javascript.

 

If you need JS, I am not sure if your context is your browser or NodeJS. The following comments apply for both.

You could use the K2Service API. This is a RESTful API so you can call it with javascript.

Luckily, to start processes, you can use one of the 2 available methods. There is a simple one using GET and a more advanced version using a POST request.

You will find no problem calling either in NodeJS.

 

If you run your code within a browser however, you may have more issues with the POST. The GET method in the browser will also work easily.

The issue with the POST request is that what is required by the K2 API makes it a non 'simple' request. That means that your browser will NOT let you perform this request without a little more checks (see CORS). In the case of a POST, you will get a 401 (auth error) status code and you will have to handle the preflight.

 

I hope this helps.


Reply