cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Animoroly
Level: Powered On

Seperating values using compose

Hello there,

 
I have 2 values on "Apply to Each". On the first value, i do a "Get Items" of another list that returns me 3 emails, and in the second value, i get 4, where i add it on a variable. 
Then I try to make a "Compose" to get all the 3 emails in a variable and 4 in the another. 
The first value, everything is fine (returns me the 3 emails), while in the second one, it adds the 3 emails to the 4 (returns 7 emails).
 
How can I do to return me the emails separated. On the first 3 emails and on second 4 emails ?
 
Untitled.pngUntitled2.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Seperating values using compose

Hi @Animoroly 

 

This is happening because you are appending the values to the same array. So you say that the values that will come in the first step will be dynamic right? so what you can do is, initialise an array variable at the top. the next action is the "compor 2" after this in the apply to each loop (here you are applying to each value of the "compor 2") and in the Get Items action iside of this loop, in the get items action add a filter query (so example in my compor 2 i get a value "1960" and in the other sharepoint list I have a column that has these numbers and you are checking with this cilumn value as 1960 so in the filter query the expression is Column eq current item-- column is the name in the other SP list and you select the current item from the dynamic selector and put that into single quotes and it should look like this 'Current Item'). Please refer to the flow screenshot below and replicate. Note that there are two apply to each loops and in the second loop we just have the append varaible action and in the first loop we have the other actions.

ddd.png

Hope this Helps!

View solution in original post

12 REPLIES 12
Dual Super User
Dual Super User

Re: Seperating values using compose

Hey! Looks like you are using the same variable in both the actions. If you are doing a "Append to array variable action' then you do not need the compose action. As the array will get the values. and for the second one, I feel you are using just one variable and put that in both the places. You should initialise another array variable and use this one for the 4 emails. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Animoroly
Level: Powered On

Re: Seperating values using compose

Hello @yashag2255 ,

 

I used the compose because I need it to send an email to these emails I get.

I can't remove the compose, the email don't accept variables.

Dual Super User
Dual Super User

Re: Seperating values using compose

@Animoroly 

 

Is it an array variable that you are using? (I am talking about the variable) and if so, then you do not have to add the compose action. You can initialise two array variables and use the append to array variable in the loop instead of the set variable so that these variables can get the emails separately. 

Animoroly
Level: Powered On

Re: Seperating values using compose

@yashag2255 

I am using the append to array variable in the loop.

But I don't understand how I save the informations on 2 variables, can you do an exemple?

Dual Super User
Dual Super User

Re: Seperating values using compose

Hi @Animoroly 

 

Please refer to the flow below: tets.png

I am getting values of email from 2 different sharepoint lists and adding those to two different varaibles. Append to array variable action will get all the emails in every iteration as the data exists. you will not need to use the compose action. you can simply refer the variable in your consecutive actions. Hope this Helps!

Animoroly
Level: Powered On

Re: Seperating values using compose

@yashag2255 

 

your solution is valid, but before that I do another apply to each, and I never know how many values I will get. This time was 2, but it can be more or less.

Dual Super User
Dual Super User

Re: Seperating values using compose

Can you share a full screenshot of your flow so that I can assist you better? No matter how many loops you have, you can have separate arrays for separate SP lists.

Animoroly
Level: Powered On

Re: Seperating values using compose

@yashag2255  Sure,

 

First I have a compose quere I get a list of numbers from another list. It returns me this ["1959","1960"]. In this case I have only 2 numbers, but it could be 1,3, or more...

Then, for each number of the list I compare it with another list to get the items who have a columns with these numbers and next for each item I get I append the email of the column to an array variable. For the first number of the list "1959" I get 3 emails, and for the second "1960" I get 4 emails (I demonstrate it on the image below).

After this I want it to get the first 3 emails and send an email, and the other 4 emails and send another email. Like this:

First email: one@email.com;two@email.com;three@email.com

Second email: one@email.com;two@email.com;three@email.com;four@email.com

 

I tried with the compose, but because it is on the first for each (to send me exactly 2 emails because the list has 2 numbers)  for the first number it returns me the first 3 emails (witch is ok), and for the second it returns me 7 emails (the fisrt 3 and the other 4 emails). It joins all the emails. And I want the 3 separated from the 4 emails.

 

Hope you understand my problem...

 

Untitled.png

 

Untitled.png

 

 

 

Dual Super User
Dual Super User

Re: Seperating values using compose

Hi @Animoroly 

 

This is happening because you are appending the values to the same array. So you say that the values that will come in the first step will be dynamic right? so what you can do is, initialise an array variable at the top. the next action is the "compor 2" after this in the apply to each loop (here you are applying to each value of the "compor 2") and in the Get Items action iside of this loop, in the get items action add a filter query (so example in my compor 2 i get a value "1960" and in the other sharepoint list I have a column that has these numbers and you are checking with this cilumn value as 1960 so in the filter query the expression is Column eq current item-- column is the name in the other SP list and you select the current item from the dynamic selector and put that into single quotes and it should look like this 'Current Item'). Please refer to the flow screenshot below and replicate. Note that there are two apply to each loops and in the second loop we just have the append varaible action and in the first loop we have the other actions.

ddd.png

Hope this Helps!

View solution in original post

Animoroly
Level: Powered On

Re: Seperating values using compose

Hello @yashag2255 ,

 

What did you set on the join of Send an Email ?

Dual Super User
Dual Super User

Re: Seperating values using compose

@Animoroly 

Here, the variables('List 1') is my array varaible that gets the email ID and i am separating every value using a ';'

join(variables('List 1'),';')

Hope this Helps!

Highlighted
Animoroly
Level: Powered On

Re: Seperating values using compose

Hello @yashag2255 ,

 

It worked! Thank you a lot 🙂

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,021)