How to check if a workflow is running via script

Katie A
Mega Guru

I need to programmatically check if a workflow is running. I need to run a specific function when the workflow reaches the END state.

I am starting a workflow in a Script Include.

How can I check when the workflow has reached the END state in the same script?

var wf = new Workflow();

//Get the workflow id

var   wfId = wf.getWorkflowFromName("Global Hostname Check if Taken");

    var vars = {"u_hostname": "hostname123"};

var context = wf.startFlow(wfId, current, current.operation, vars);

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

We usually glide record wf_context table and get the record using context id (you already have in above script). Now if that context is active means workflow is still running otherwise its end or canceled.


View solution in original post

1 REPLY 1

Gurpreet07
Mega Sage

We usually glide record wf_context table and get the record using context id (you already have in above script). Now if that context is active means workflow is still running otherwise its end or canceled.