cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dww1962
Frequent Visitor

How do I find where a Collection is created?

Is there an easy way to find the place in an app where the Collection is created versus looking through each component?

6 REPLIES 6
Sienna
Resident Rockstar
Resident Rockstar

Go to File -> Collection or View -> Collection

col.png

dww1962
Frequent Visitor

Yes, I know how to go look at the collection.  What I want to know is the place or action in the app the actually creates the collection via Collect, ClearCollect, etc. for example in an OnVisible action or OnSelect action.

Sienna
Resident Rockstar
Resident Rockstar

ahh.. then answer is unfortunately no. 

DeeTronSEAM
Kudo Collector
Kudo Collector

Some info for people struggling with "Where The Hell DID I create that collection"......

 

First of all, vote for at least ONE of these two ideas/suggestions. 

 

1) https://powerusers.microsoft.com/t5/Power-Apps-Ideas/How-do-I-find-where-a-Collection-is-created/idc...

 

2) https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Show-all-references-to-a-collection/idc-p/67116...

 

The PApps team has them as Under Review but they seem to be stuck there.  More votes will get that moving, hopefully.

Also, in the meantime, there are at least two workarounds/hacks for locating where a collection is defined (e.g. ClearCollect, Collect).

 

I describe one method using a .zip export of the app in the aforementioned threads here (and I'm now pretty certain the person I should have given credit to for that trick is @TML , btw) :
https://powerusers.microsoft.com/t5/Power-Apps-Ideas/How-do-I-find-where-a-Collection-is-created/idc...

 

But here is the newest method I've become aware of...and it may be the better way.. though still deciding on that....

I.e. the "PowerAppps Review Tool" available here: https://github.com/microsoft/powerapps-tools#powerapps-review-tool

 

It allows you to export an app as an MSApp file and see all your functions, and it highlights what formulas/properties have been changed from the PApps default values.  You can export the report as JSON or HTML.  This is easier than the export as .ZIP and extract method I described.

 

Do be aware that the tool can APPEAR to hang (e.g. Not Responding) when you open your MSAPP file.   I.e. it can take SEVERAL minutes for the tool to chew through the app and generate the report.

 

Here is an example screenshot of a report:

ExamplePAppsRevToolReportSS.png

CrashWave
Advocate I
Advocate I

My Work Around
Instead of a collections I created Variable Tables. Happened by accident and they work. Stakeholders kept changing how they wanted things named, from lists to column names to lookup items. So I put everything in OnStart and can all be changed from there so none of my code breaks.
example

Set(varListName, 'ListName')

There were only a few places in my app that I actually needed to create a collection. One is where I needed to add the "New" item selection to a combo box 
For that I did

ClearCollect(collectListName, varListName ); //Where varListName is created in OnStart from the SP list
Collect(collectListName, { Title: "New", ID: 0 }

 

Also if you need to use collections you can also assign a dummy variable like

ClearCollect(collectListName, ListName ); Set(varCollectListName,Blank()))

and that way you will always find the collection

 

Hope that helps someone

Thanks much, @CrashWave !  I especially like the idea of using the global var "tagging" to make it easier to locate collection creations.  PITA that we have to do such a workaround, but your technique is MUCH easier than doing the export/search technique to hunt collection instantiations.  That even extends to allow you to use it to record what/when the collection was modified.  E.g.

 

ClearCollect(coll_ItemsRequiringCollectionUsage, 'dbo.MySQLViewName' );
Set(global_var4coll_ItemsRequiringCollectionUsage
, {"LocationModified : "App.OnStart Line 35", "TimeStampModified : Now()}
);

 

I'm pretty **bleep** certain you've sold me on that idea!

 

As for using (global) table variables instead of collections, that's also a great idea....but I'm a bit more hesitant on using that as I've become (too?) comfortable with collections as my "data table" objects.  But, I'm seeing occasional weirdness with ClearCollect not always clearing (forcing me to now "belt&suspender" every ClearCollect by adding a preceding Clear). Perhaps that strangeness coupled with your suggestion is enough to force me to abandon collections going forward.  If you bump into any other "gotchas" or lessons-learned from using table vars instead of collections, it would be great to hear them.

 

Thanks so much for sharing!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,165)