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

PowerApps: Return TaskID when creating Planner tasks in bulk using ForAll

In PowerApps, I need to create sets of tasks associated with a single Plan and Bucket.  The code I use is this:

 

ForAll(SelectedMeetingTasks,Planner.CreateTask(SelectedMeeting.PlanGUID, title,{bucketIdSmiley FrustratedelectedMeeting.BucketGUID,dueDateTime:AssnTaskDueDate,assignments:AssignToUser.Id}))


It properly creates the tasks, but I am unsure how to return the Task IDs after the tasks are created.  Not sure if I need to wrap this in another command. 
The only examples I have seen return the ID are processed one by one and not using the ForAll.
I need to update other systems with the newly created IDs. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
strategery
Level 8

Re: PowerApps: Return TaskID when creating Planner tasks in bulk using ForAll

 

CreateTask should return the created task as a record, so wrap it in Collect. Put it inside the ForAll and it should grab each task created as a new record in the collection. Put Clear in front of it if you need a fresh list each time this ForAll runs

 

Clear(createdTasks);ForAll(SelectedMeetingTasks, Collect(createdTasks,Planner.CreateTask( ... ) ) )

2 REPLIES 2
Highlighted
strategery
Level 8

Re: PowerApps: Return TaskID when creating Planner tasks in bulk using ForAll

 

CreateTask should return the created task as a record, so wrap it in Collect. Put it inside the ForAll and it should grab each task created as a new record in the collection. Put Clear in front of it if you need a fresh list each time this ForAll runs

 

Clear(createdTasks);ForAll(SelectedMeetingTasks, Collect(createdTasks,Planner.CreateTask( ... ) ) )

BraneyBI
Level: Powered On

Re: PowerApps: Return TaskID when creating Planner tasks in bulk using ForAll

Fantastic!  Worked like a charm!  
The way you explained it makes SO much sense.  Thank you for adding to my further understanding of the PowerApps coding language. 

Helpful resources

Announcements
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

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 239 members 4,440 guests
Please welcome our newest community members: