Solved

How does one determine how a workflow was called at runtime?

  • 27 October 2021
  • 7 replies
  • 91 views

Userlevel 5
Badge +16

I have a workflow that can be run by hand or called by another workflow.

I need to be able to determine how the workflow was called.

 

Does anyone know how to determine this?

Thanks.

icon

Best answer by Chris Sunderland 27 October 2021, 19:36

View original

7 replies

Userlevel 7
Badge +23

That’s a good question….so essentially you want to know if the Workflow was run manually, or as part of another Workflow and how to determine which?

I’ll inquire within.  I’m sure the Workflow logs will mention if it was interactive or not, though I’m not sure if that’s enough for you.

Userlevel 3
Badge +6

Inside the workflow, you can add a script activity which makes a check like such

workflow.getWorkflowId() == workflow.getRoot().getWorkflowId();

This check would return True if the workflow was called directly and false if it was executed inside a parent workflow.


 

Userlevel 5
Badge +16

That’s a good question….so essentially you want to know if the Workflow was run manually, or as part of another Workflow and how to determine which?

I’ll inquire within.  I’m sure the Workflow logs will mention if it was interactive or not, though I’m not sure if that’s enough for you.

That is exactly what I am looking for. I am writing my workflows so they can either be called by external rest calls or ran internally via other workflows, which means the way workflow functions changes based on how it was run.

Userlevel 5
Badge +16

Inside the workflow, you can add a script activity which makes a check like such

workflow.getWorkflowId() == workflow.getRoot().getWorkflowId();

This check would return True if the workflow was called directly and false if it was executed inside a parent workflow.


 

This is awesome, but it does beg a few questions.

Is there a way to interrogate methods?

Userlevel 5
Badge +16

Inside the workflow, you can add a script activity which makes a check like such

workflow.getWorkflowId() == workflow.getRoot().getWorkflowId();

This check would return True if the workflow was called directly and false if it was executed inside a parent workflow.


 

I’ll try this.

Userlevel 7
Badge +23

@christopherlecky let us know if this gives you what you need!

Userlevel 5
Badge +16

Inside the workflow, you can add a script activity which makes a check like such

workflow.getWorkflowId() == workflow.getRoot().getWorkflowId();

This check would return True if the workflow was called directly and false if it was executed inside a parent workflow.


 

Just figured I would circle back to tell you this worked like a charm.

 

Thank you.

Reply