Loop the entire logic app based on array string parameter for eg ["abc","xyz"]

Srinivas Mehenderker Nath 86 Reputation points
2022-11-30T12:41:13.63+00:00

In my logic app, I would like to execute the entire flow for steps connecting to dynamic database based on parameters. Suppose parameter 1 in the array is a "abc", I would like to conditionally execute the logic app with a specific connector to sql server. And for parameter "xyz", it should execute with a different connector.

I am trying to use the for each approach after initializing an array variable, however on Saving it says "Definition contains invalid parameters"

Kindly share an overview of approach to the above requirement of conditionally processing based on input array parameters.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alistair Ross 7,466 Reputation points Microsoft Employee
    2022-11-30T15:24:00.447+00:00

    Hello @Srinivas Mehenderker Nath

    I've made simple Logic App with performs the following actions

    1. Initializes a variable array with the values
    "A","B","C"    
    
    1. Initializes an empty variable for the output (You do not need to do this, as your output would be the SQL connection in the for each loop)
    2. Iterate through the array using the for each function
    3. Using a switch, evaluate the current item and set the empty variable value

    265814-image.png

    You can download the sample code from here 265813-template.txt. This should give you an understanding of how you can use switches inside a for each loop to perform different actions based on the value. Instead of setting a variable, it could be performing the SQL connection.

    I hope this helps provide you with the information you need. If it does, please make sure to mark the question as answered so it helps other people in future.

    Kind regards

    Alistair

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.