Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ZHcQds55GYoL5MmUK4UNB1
Power Automate - Building Flows
Unanswered

Get variable inside a power automate expression

Like (0) ShareShare
ReportReport
Posted on 10 Nov 2021 20:30:09 by

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

JayBert_0-1636575758293.png

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):

JayBert_1-1636575953695.png

outputs('adc')?['body/data']?[variables('code')]
 
 
I don't know if this all make sense. Thanks
  • Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 12 Nov 2021 at 12:32:57
    Re: Get variable inside a power automate expression

    Hi @Anonymous,

     

    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?

  • Community Power Platform Member Profile Picture
    on 11 Nov 2021 at 15:20:51
    Re: Get variable inside a power automate expression

    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_')

    JayBert_0-1636643151806.png

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

    context/exemple:

    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):

    JayBert_1-1636643641010.png

    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.

  • Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 11 Nov 2021 at 08:59:41
    Re: Get variable inside a power automate expression

    Hi @Anonymous,

     

    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:

    concat(outputs('adc')?['body/data']['somefield'],variables('code'))

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 14

#2
Churchy Profile Picture

Churchy 12

#3
rzaneti Profile Picture

rzaneti 8 Super User 2025 Season 1

Overall leaderboard
Loading started