Skip to main content
Answer

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

  • October 27, 2021
  • 7 replies
  • 101 views

christopherlecky
Novice
Forum|alt.badge.img+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.

Best answer by Chris Sunderland

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.


 

7 replies

Mike Struening
Vaulter
Forum|alt.badge.img+22

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.


Forum|alt.badge.img+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.


 


christopherlecky
Novice
Forum|alt.badge.img+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.


christopherlecky
Novice
Forum|alt.badge.img+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?


christopherlecky
Novice
Forum|alt.badge.img+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.


Mike Struening
Vaulter
Forum|alt.badge.img+22

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


christopherlecky
Novice
Forum|alt.badge.img+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.