cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Beat
Level 8

Creating multiple target list items based on values in the source list

I have a requirement for automatically creating multiple items in a target list, whereby the number of items to be created and their contents are driven by a source list, sort of transpose and expand.

 

Data in SourceQ1Q2Q3Q4
A12,501,5
B0120
     
Result in Target    
A-Q11   
A-Q21   
A-Q21   
A-Q20,5   
A-Q41   
A-Q40,5   
B-Q21   
B-Q31   
B-Q31   

 

In a nutshell, for each item in the source list, create as many items in the target list as specified in each column.

If column Q2 for item A is 2.5, I need 3 items in the target list, 2 with a value of 1 and the 3rd with a value of 0.5.

I figured out the innermost part by setting a variable, then a do until loop variable <= 0 with the output formula

if(greaterOrEquals(variables('thisQuarterValue'),1),1,mod(variables('thisQuarterValue'),1))

and then decrement the variable by 1.

 

That works just fine, but now I need to assure that new items are only created for the item that was modified in the source list and triggered the flow. I applied an array filter after the Get items action, tried comparing both, Title and Title Id from  "when an item is created or modified"  with Title resp. Title Id from the Get items array, but to no avail, the workflow completes with no error but creates the new records for both, row A and row B in the source list, no matter which one I modify to trigger the flow.

 

Any suggestion? Thank you!

 

3 REPLIES 3
Beat
Level 8

Re: Creating multiple target list items based on values in the source list

No way to get this to work, Apply for each affected all records from Get items.

 

Filter Array.png

 

Instead, added another condition within the Apply for each section:

 

Condition2.png

 

So this does the trick just fine, but not very elegantly. What could be wrong with my Filter Array?

 

Community Support Team
Community Support Team

Re: Creating multiple target list items based on values in the source list

Hi @Beat,

 

Do you want to create new item within the target list for an existing item is modified within your Source list?

Could you please share a screenshot of your flow's configuration?

 

If you could provide more details about your scenario, we would provide a proper workaround for you.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Beat
Level 8

Re: Creating multiple target list items based on values in the source list

Yes I want to create multiple items in the target list, based on data in source list items, but it's actually triggered when an item is changed in a third list which has a key to items in the source list.

 

So when an item in the triggering list is modified, the flow should make a collection of all matching entries in the source list and then create items in the target list. I figured out the workaround, using another condition within the Apply to each loop, but that's not very elegant, as it will cycle through all items in the source list skipping those that don't match the key from the triggering list.

 

Here the screenshots:

 

trigger and check if status is approved.png

 

If Status equals approved, get items from the Source list and filter the array for items where the title matches the key from the triggering list stored in thisPlanTitle:

 

get items and filter array.png

 

And that's where it fails. The subsequent Apply to each loop will act upon all items in the source list, not only those where the title matches the key from the triggering list.

 

Here the workaround: adding a condition within the apply to each section

 

condition 2.png

 

I then thought well, of course the Filter Array must be within the Apply to each section in order to work!

 

filter array within apply to each.png

But no, that makes of course no sense and didn't solve my issue. So I'm going to keep the Condition within the Apply to each cycle, as long as there are not hundreds or thousands of items it won't matter much, but still I would like to understand why Filter Array after Get Items is not filtering the items correctly.

 

 

 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Users Online
Currently online: 299 members 4,467 guests
Please welcome our newest community members: