web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Build a Collection fro...
Power Apps
Answered

Build a Collection from another Collection

(0) ShareShare
ReportReport
Posted on by 99

I'm stuck on something and am hoping someone can help me.

 

I have an app that is used to track time on project tasks. Each Project has an associated Task List (all of my data sources are SharePoint lists). From the Project Task List screen, stakeholders want to be able to "pin" tasks to their timesheet. So that when they click on a Timesheet button, they will be served up with a gallery of tasks that they have pinned to their timesheet.

 

On my Project Task list, when a user clicks on the "pin" icon in the screenshot below, I add a record to a CSUserPinnedTasks SharePoint list. That list stores:

  • UserName
  • UserEmail
  • TaskID (from my CSProjectTasks list)

This part is working fine.

 

tsparkman_0-1623360468471.png

 

On my Timesheet screen I'm trying to dynamically serve up a gallery of tasks for the logged in user. I'm creating one collection called ColPinnedTasks that stores the TaskIDs for the logged in user, from the CSUserPinnedTasks list. This part is also working and I can see that it is collecting the data correctly.

 

Now I'm trying to create second collection called ColPinnedTaskDetails that loops through the IDs in the first collection to pull the task details from my CSProjectTasks list where the ID in the CSProjectTasks list matches the TaskID from the first collection. This is the formula that I have in my Timesheet screen OnVisible property.

 

ClearCollect(ColPinnedTasks,CSUserPinnedTasks);
Clear(ColPinnedTaskDetails);
ForAll(ColPinnedTasks,
		Collect(ColPinnedTaskDetails, CSProjectTasks, ID=ThisRecord.TaskID));

 

The ColPinnedTasks collection is working and my formula is not giving me any errors, however, the ColPinnedTaskDetails collection is not capturing any records.

 

Any help or insight is greatly appreciated!

 

 

Categories:
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @tsparkman Try this,

    ClearCollect(ColPinnedTasks,CSUserPinnedTasks);
    ClearCollect(ColPinnedTaskDetails, Filter(CSProjectTasks, ID in ColPinnedTasks.TaskID));
  • tsparkman Profile Picture
    99 on at

    Hi @CNT - you should change your username to TNT because you are dynamite 😁! Thank you so much for your help!

     

    This worked, but I did have one follow-up question. It's giving me a delegation warning due to the use of "in". I'm wondering whether I should be concerned about it or not. The ProjectTasks list could get rather large (in fact it is already over 2000 records). However, since we are looking for the ID from that list in the ColPinnedTasks collection (which should be fairly small), do you know if that is going to cause an issue?

     

    I still don't fully grasp delegation and how to work around it.

  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @tsparkman Delegation isn't such a tongue twister as it sounds. PowerApps doesn't like to carry too much in its belly as it will make it ache. So, it tells (delegates to) the originating datasource to send only stuff that it can handle. But, when the originating datasource says, "well I don't know how to do that (non-delegable queries, operators etc.,)", PA then says, "well then just given me 2K and no more please." I hope this clears the mist.

    So, wisdom says, either use a delegable query (that involves operators that are delegable) or narrow your query down, so that it's not going to be more than 2K records.

    In your case, if its more than 2K records we will have to collect them in batches. Give this a try,

    ClearCollect(ColPinnedTasks,CSUserPinnedTasks);
    Clear(ColPinnedTaskDetails);
    ForAll(ColPinnedTasks,
    	Collect(ColPinnedTaskDetails, Filter(CSProjectTasks, ID = TaskID))
    );

     

  • tsparkman Profile Picture
    99 on at

    Hi @CNT -- thank you so much for the explanation and for helping me with the formula. This is exactly what I was trying to accomplish, but I probably would have spent many hours (or days) trying to get it right!

     

    I am so grateful for your help!

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @tsparkman Glad to help!

     

    Please remember to give a 👍 and accept the solution as it will help others in the future.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard