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.
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!
Proud to be a Flownaut!
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.
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!
Proud to be a Flownaut!
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.
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
Proud to be a Flownaut!
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:
User | Count |
---|---|
92 | |
44 | |
21 | |
19 | |
17 |
User | Count |
---|---|
144 | |
51 | |
42 | |
40 | |
31 |