cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
adavana
Frequent Visitor

Use compose action outputs outside the for each loop

I am creating a flow where there are two apply to each loops.

in the second for each loop ihave used compose action to fetch first record in the array. (email)

I am tryin to use the same value outside the inner loop, where send email acition will be using the output as To address. I am unable to find it under dynamic content.

 

is there a workaround in place to use outputs in inner loop to access outside in the email action.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sudharsan1985
Super User
Super User

Hi @adavana 

Use the action Initialize variable before the Apply to each action and set the output of the compose action to the variable using the Set Variable inside the Apply to each. After the Apply to each action, you should be able to access the variable. Try it and let me know.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

View solution in original post

5 REPLIES 5
sudharsan1985
Super User
Super User

Hi @adavana 

Use the action Initialize variable before the Apply to each action and set the output of the compose action to the variable using the Set Variable inside the Apply to each. After the Apply to each action, you should be able to access the variable. Try it and let me know.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

View solution in original post

adavana
Frequent Visitor

Hi @sudharsan1985 

 

Thanks for the inputs. That worked. I have one more question which I thought would be solved by the above solution but dint.

 

I am using the compose action to fetch first record from apply to each action (with union funtion)

 

for every union of values I need first record (here I am trying to get email)

 

my compose action to fetch first record: 

first(body('Exceltable')?['Value'])?['Email']
 
output: 
body('Exceltable')?['Value']?[0]?['Email']
flow snip:
Capture.PNG

 

I am then getting the o/p of body inside an external send email block as To address.

 

The issue im facing is, the flow is picking the topmost/first email in the excel column but not the first email for every union of values. 

 

can you please check where I am doing wrong. Thanks!

sudharsan1985
Super User
Super User

Hi @adavana 

If I understood correctly, the second loop is looping the values from Union function. Since the Set Variable is inside the second the loop, the value should be from the Union output. Please check the function used to assign the value to the variable, something is wrong on the set variable, check whether you are assigning the value from the Union values.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...
adavana
Frequent Visitor

what input inside the first function I need to be giving for using outputs of union. I gave the 'name of the array', outputs('name of the array') and didnt get the results but got an error. at the compose action block.

adavana
Frequent Visitor

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (36,655)