cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Count loop iterations

Hello good afternoon,

 

I created a flow that sends an email every time an attachment is added to a note in my model driven app.

 

But I receive an email for every loop of apply to each of my flow.

 

I wanted to know how can I send only one email (the last loop) to the person designed to receive that notification.

 

My idea was to count the loops and make a condition to send the email to the last loop but I can't make it work.

 

Can you help me?

 

Print screen of the flow.

ticket count int 1.JPGticket count int 2.JPGticket count int 3.JPGticket count int 4.JPG

6 REPLIES 6
efialttes
Super User
Super User

Hi!

Did you try to move "Send an email notification" outside the 'Apply to each'?

If the editor does not allow you to move it outside... can you share a sceenshot from your 'Send an email notification' action block so we can see which data did you assign to its inputs?

Hope this helps!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Anonymous
Not applicable

Hello good afternoon @efialttes ,

 

Thank you for your answer.

 

I tried to put the email notification outside but if I do that I cannot have the dynamic values from the get records.

 

Print screen of email notification.

 

ticket count int 5.JPG

So you need to add to your email body a list with all 'Tarefas id' since I guess 'Get records' is providing more than one record, right?

Do you get 'Tarefas id' as an output from 'Obter registro do pedido do tarifa' action block?

If so, my suggestion is to add a 'Initialize variable' action block before the 'ApplyToEach', name 'myOutputTarefasIds', type Array, value 

[]

Then inside Apply to ech, after 'Obter registro do pedido de tarifa' add an 'Append to array' action block, nme 'myOutputTarefasIds', assign as its value 'Tarefas id' output from the last action block

Now, outside the apply to each, add a Compose action block, assign as its input the following expression:

join(variables('myOutputTarefasIds'),'
')

Reexecute your flow, inspect Compose content and verify the list of 'Tarefas Ids' is there

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Anonymous
Not applicable

Hello good afternoon @efialttes 

 

Thank you very much for your answer.

 

I thing that is a good solution to take the values out of the apply to each to use it outside.

 

I did what you explain and successfully get the list of "Tarefas Id" outside of the loop, but now I have another problem.

 

Applying that solution I want to get the last "Tarefas Id" value of the compose, the problem is that the compose return an object and not an array or string and I can't get the value.

 

Can you help me with this?

 

I send you a print screen.

 

ticket count int 6.jpgticket count int 7.jpg  

Hi!

I would remove your select.

In order to get the last element of 'myOutputArray' you just need the following expression:

 

last(variables('myOutputTarefasIds'))

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Anonymous
Not applicable

Hello good morning @efialttes 

 

Thank you very much for your answer.

 

I did it has you said and could get the values of the loop, but the problem is that the loop scramble all the values and I cannot get the last created value.

 

I tried to associate the value created on but cannot been able to work on a field the last created on value.

 

Do you know a way to get this problem solved?

 

Best regards.

 

Print screen:

ticket count int 8.jpgticket count int 9.jpg

Helpful resources

Announcements
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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Top Solution Authors
Users online (2,400)