Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Get variable inside a power automate expression

Hi, Im trying to make a dynamic adaptive card that show input dynamically depending on some data fetch from my database, so far i've done quite good. But I'm stuck here. When i get the output from the adaptive card i try getting my field by a generated id with an iterator number (ex : id_iterator) so that i can loop, fetch the data and create a row in my db) but i can't manage to insert my variable inside my expression without creating a string variable before for each of my field. which i don't want to do... this is what i got so far


and my expression is as followed : outputs('ad')['body/data']['Fournisseur_variables('iterator2')']

but it keep saying it's not valid. is there a to inject the variable after the '_' ?


other thing i tried that work (while i was testing to make sure it could work first). i just initialize the variable to inject instead of trying to get the input directly in the expression (this is what i try to avoid):


I don't know if this all make sense. Thanks
Super User
Super User

Hi @JayBert,


If I understand your requirement correctly a concat function might help.


Which field from ADC action do you want to use in your expression together with the variables code?


Below is an example of a concat:



Frequent Visitor

Hey thanks for the answer, i've tried it, and while the expression is valid, i'ts not working in my case... (Edit: i think it's because the expression is processing outputs() before concat() so it doesn't find my 'inputId_')


I'm trying to get all id_x where x is the iterator value


let's say i have a task table, and a people table, a person can have many task. I get all the task of a user, and build a card and send them the card with an input for each task to know if they have done it. But since i don't know how much task they had, and i want to send this card to each of them respecting their individual task. all card must be build dynamically. 

So i manage to build the card dynamically. so it could look like this when the user receive it (exemple, i just simplified my context) cause as you can see in my error. i have many more field. wich is why i don't want to declare a variable for each of them):


so each row was added dynamically with the id -> Task_X. so when i get the card i want to do something like:

for( int i = 0; i < rowcount; i++)


     get my field value dynamically (Task_i)




Sorry if it's still not super clear... it makes sense in my head. for now i'll go for my solution that i wanted to avoid since i know it's working... i'll wait for your input.

Super User
Super User

Hi @JayBert,


It does make sense. You want to dynamically determine what the correct field is to retrieve in the expression. You want to do that by using an iterator and to apply the code variable with the correct incremented integer value. So if you would be in row 3 of your do while loop, the field in the expression you want to retrieve would be Fournisseur_3. 


However, it looks like the expression editor can't handle this kind of logic. I have also tried several things. It will just output the variable as a string and doesn't use it to retrieve the correct field.


I am interested in the actions before your do while loop. We might be able to find a workaround for this. Can you share the first part of your flow with the ADC action?

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (6)