Skip to main content
Answer

Function to trigger multiple instance of workflow

  • April 12, 2024
  • 3 replies
  • 62 views

I am trying to trigger multiple workflow through function.

 

I have a function(function name = "wk-func") that will trigger workflow instances(workflow name = ra-wkflw'), it has for loop , number of times workflow instances to be created, keeping in mind instances limit to be 50, still it is giving error for run on even 2 isntances, Function has following handle:

 

def handle(client,handle):

      for chunk in chunks(list,2):    

        workflow_input = {

            "abc":data['value']

        }

        run = client.workflows.executions.trigger(

            workflow_external_id='ra-wkflw', version=1,input=workflow_input

        )

 

Its working if I run at my local IDE with passing the client details and trigger function handle. It triggers multiple workflows without any error.

However, On running function using SDK,

input_data = { ‘abc’:’hey’}

client.functions.call(external_id ="wk-func", data = input_data)

Function is completed, however, workflow instance is not being triggered and following error is there

'Sessions chaining depth limit exceeded' 

Can you guide for running multiple instance of workflow through SDK

 

Best answer by Jørgen Lund

Hi @Rimmi Anand, can you try using client credentials when triggering the workflow from the Funciton? As documented here (client_credentials paramter), and with an example here.

3 replies

  • Author
  • Seasoned
  • April 12, 2024

Tried running SDK,

input_data = { ‘abc’:’hey’}

client.functions.call(external_id ="wk-hybrid-func-0", data = input_data)

Function is completed, however, workflow instance is not being triggered. 


Jørgen Lund
Seasoned Practitioner
Forum|alt.badge.img
  • Product Manager
  • Answer
  • April 15, 2024

Hi @Rimmi Anand, can you try using client credentials when triggering the workflow from the Funciton? As documented here (client_credentials paramter), and with an example here.


  • Author
  • Seasoned
  • April 15, 2024

Thank you . It worked