cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AAallday
Helper I
Helper I

Stop Apply to Each on Assigned To Person

Hello

I have a list that includes a Assigned To field in which we assign multiple users (listed as person profiles in the list). The flow creates a new list item when one is completed. The new list item should have the same users assigned but flow adds an "apply to each" so that I get a new item for each assigned user.

AAallday_0-1611966457665.png

I saw on an old thread that this may not be possible? but it was a few years back so wanted to see if there's a workaround for it?

1 ACCEPTED SOLUTION

Accepted Solutions
DAllen365
Resolver III
Resolver III

@AAallday,

 

If I am understanding you correctly, I believe you are wanting to create a list item and set a person group field with multiple users (which is copied from a source list item).  This is absolutely possible, albeit I would think this is a much better solution than what you do.  In my solution, I just do a foreach on the people, and append a JSON string to an array variable.  Then I use that array variable in the create item action.  

 

First we need to built an array listing of our people.  I wrap an Append array variable action inside a foreach which runs on the source people field.  I write the claims value of it in this structure:

 

{
"Claims": @{items('Foreach_Approvers')?['Claims']}
}

 

mutiple_people_action.png

 

Then use that variable in the create item action:

update item multiapprovers.png

 

Let me know if you have any questions or if I misunderstood your need.  


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

9 REPLIES 9
DAllen365
Resolver III
Resolver III

@AAallday,

 

If I am understanding you correctly, I believe you are wanting to create a list item and set a person group field with multiple users (which is copied from a source list item).  This is absolutely possible, albeit I would think this is a much better solution than what you do.  In my solution, I just do a foreach on the people, and append a JSON string to an array variable.  Then I use that array variable in the create item action.  

 

First we need to built an array listing of our people.  I wrap an Append array variable action inside a foreach which runs on the source people field.  I write the claims value of it in this structure:

 

{
"Claims": @{items('Foreach_Approvers')?['Claims']}
}

 

mutiple_people_action.png

 

Then use that variable in the create item action:

update item multiapprovers.png

 

Let me know if you have any questions or if I misunderstood your need.  


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

AAallday
Helper I
Helper I

Thanks @DAllen365!!  let me restate and see if this is what your solution addresses.

1. SharePoint list has Assigned To field, in which I enter multiple users (i.e. 3 people are assigned to the "task")

2. When the list item is modified to "completed" the flow is triggered to create a new item for next year

3. the new item should be assigned to the same (multiple) people in the original item

 

The problem is the "apply to each" that pops up creates a new item (step 3) for each of the users, individually/separately (i.e. a "task" with 3 users assigned, will result in 3 new items for next year).

 

Hope this helps

@AAallday Hello, yes my offered solution will do exactly what you want to do.  Instead of using the direct field in your create item action (which generates the apply to each you don't want), we manually build an array of those 3 people into a varriable.  Then inside a single create item action, for the people field use the variable to populate it.  My method will create 1 item with 3 people in the assigned to field.  Give it a try and let me know if you have any questions!


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@DAllen365 i'm not super skilled in flow, but i am not able to find any of the containers you have there (foreach, append approvers, collect people), did you rename?

 

I have an "append variable" is that same? and if so, there no option for the name of the variable

@AAallday, sorry about that I don't mean to be confusing.  The Collect People Claims is a Scope action, and that isn't needed in your case.  The foreach is called Apply to each, and the purple Append approvers is just called Append array variable action then I renamed them.  Your flow would function like the following:

 

  • Initialize variable - choose type Array, call it like AssignedToPeople
  • Condition - check if Complete
  • If yes
    • Apply to each - Assigned To (claims)
      • Append to array variable - AssignedToPeople
    • Create item
      • Assigned To = AssignedToPeople

The easiest way to do the apply to each is just add the action Append array variable action, and choose the Assigned To Claims field from the original item.  It will automatically add the apply to each.  

 

Just let me know if I can expound on anything else, happy to help.  


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@DAllen365 thank you.. i keep getting an error though. i have tried different options in the appendvariable value field (assigned to claims, email...). nothing seems to be resolving correctly

Snag_3bf4f2cf.png

@AAallday I struggled with that part the most too.  You have blank above, can you please paste the exact option you are trying that is giving the error?  In your append, it should similar (but not exact) to this:

 

{
"Claims": @{items('Foreach_Approvers')?['Claims']}
}

 

Or to be more clear:

{
"Claims": <field>
}

 

Also be sure the variables are type array and not string.  


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@DAllen365 awesome --that worked (at least for now, haha). Thank you!!!

 

@AAallday Awesome!  I remember that first time I saw a green success when I was banging my head to get this to work.  Glad you got it working!


----------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (3,175)