Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

How to determine if any task is running within a workflow

Avatar

Level 2

Hi All,

 

I have a complicated workflow, which starts with an external signal. The Workflow has multiple end points and Jumps.

 

We need to determine, if any activity is running when the External Signal receives a call, if already aby activity within the workflow is already running, then we need to wait, till all the activities and completed and process the record.

 

Using isRunning, as there are multiple end points, multiple combinations to reset the variable exist, which is throwing of the purpose of that. Is there any other way to determine the running of tasks for this purpose

 

Regards,

DG

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @dganguly ,

you can take a look at the field @processDate that will tell you the last processed time

Also if you have field on workflow table called process @processId which only has number greater than zero if the worklfow is actually running.

workflow running (idle) with external signal

Marcel_Szimonisz_1-1680686026628.png

Worklfow actually running

Marcel_Szimonisz_3-1680686152729.png

 

 

Visually you can see if worklfow is running by seeing cog above the activity currently being processed.

Marcel_Szimonisz_2-1680686141617.png

 

 

Marcel

 

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Hello @dganguly ,

you can take a look at the field @processDate that will tell you the last processed time

Also if you have field on workflow table called process @processId which only has number greater than zero if the worklfow is actually running.

workflow running (idle) with external signal

Marcel_Szimonisz_1-1680686026628.png

Worklfow actually running

Marcel_Szimonisz_3-1680686152729.png

 

 

Visually you can see if worklfow is running by seeing cog above the activity currently being processed.

Marcel_Szimonisz_2-1680686141617.png

 

 

Marcel

 

Avatar

Level 2

Hi @Marcel_Szimonisz,

 

Thanks a lot...

Which table to query to get the PID?

 

Regards,

DG

Avatar

Community Advisor

Hello @dganguly 

workflow table im running version 9359 application server. You might not have it perhaps you can try to find field that does similar

 

 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Avatar

Level 2

Hi @Marcel_Szimonisz,

 

I could find the field. Just one follow up question.

In a workflow, let's say in a JS Activity can we find which task is currently being executed.

 

Use Case:

In a workflow, I have 2 branches. the first branch has long list of WF activities that are being executed.

The second branch should periodically query the workflow just to find which task is currently being executed. Can this be done ?

 

 

Regards,

DG

Avatar

Administrator

Hey @Marcel_Szimonisz,

Could you please help @dganguly further with their query here?

Thanks!



Sukrity Wadhwa

Avatar

Employee

Hi @dganguly ,

 

You should be able to look in the xtk:workflowTask schema using the workflow ID (which you will need to get from the xtk:workflow schema using the workflow internal name) and see which activities have a value in the "Running" column with a value of "Pending" in the Status column. You might be able to get away with just looking at the "Pending" status but I haven't had a chance to play around with it to know if it can be used without the "Running" column. 

Avatar

Community Advisor

Hi @dganguly 

 

You can use the below code to logInfo the activities that is running for the current workflows.

var query = xtk.queryDef.create(
    <queryDef schema="xtk:workflowTask" operation="select" >
    <select>
    <node expr="[workflow/@internalName]"/>
    <node expr="[workflow/@label]"/>
    <node expr="@activity"/>
    <node expr="@runningDate"/>
    <node expr="@status"/>
    </select>
    <where>
      <condition boolOperator="AND" expr={"[workflow/@internalName] = '"+instance.internalName+"'"} />
      <condition expr={"@status = '0'"} />
    </where>
    </queryDef>);
    
var record = query.ExecuteQuery();
if (Object.keys(record).length>0)
{
  for each(var recRecord1 in record)
  {
    if(recRecord1.@runningDate!='')
    {
      logInfo("The running Activity is "+recRecord1.@activity);
    }   
  }
}

 

Regards

A