cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Villanous81
Helper I
Helper I

Set variable from array and use in a subsequent Apply to Each step

I am trying to create Sales Quote Lines in a Business Central Sales Quote as part of a Power Automate flow. I am using an Dynamic Excel Worksheet for my values and have worked out most of the kinks in my Flow. The last issue I am having is that I am setting a variable for a column in the Excel worksheet titled Quantity via an Apply to Each loop, which is working just fine.

 

The issue I am now facing is that when I use the Outputs of that variable in a subsequent Apply to Each step (to create my Sales Quote Lines), it is only grabbing the last variable value from the Outputs versus using each one. Previously I had the Apply to Each step within another apply to each step for my HTTP Post sequence, but that was causing duplicate entries as the Apply to Each was in essence running 6 times. See below for where I'm stuck at, is there any possible way to achieve what I'm trying to do?

 

FYI I'm converting the output of my Quantity variable to an integer in the Post HTTP step "quantity":

 

Villanous81_0-1641658663924.png

 

3 REPLIES 3
vikulkar
Community Support
Community Support

Hi @Villanous81 ,

The variable being used here is a string and in the applyToEach, it is updating the same variable and finally ends up having the last value in the Quantity array.
You can consider initializing an array variable instead of just a string and inside the Apply to Each you can use "Append to array variable" action. So that the array contains all values of Quantity.

 

Thanks and Regards,

Vikas K

Great suggestion, much appreciated. Unfortunately it is now posting the entire array variable whereas I need each number sequentially in the apply to each.

 

Villanous81_0-1641747325341.png

 

vikulkar
Community Support
Community Support

To do that, you will have to iterate through each element using another ApplyToEach as shown below:

ArrayCommunity.png

Thanks and Regards,

Vikas K

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (3,270)