Ok, I'm really stumped. I have a ClearCollect function firing in the OnVisible of the page to collect records from a sharepoint list and it is missing a chunk of records. I'm supposed to get 272 records but only returns 96.
So I copied the code exactly as is into the OnSelect of a button and pressed it. It returned all 272 records. The code is identical. I don't understand why the button would return the correct # of records but not the one that's in the OnVisible event. Any ideas?
Clear(tempNetForDisplay);
Collect(
tempNetForDisplay,
ShowColumns(
Filter(
VarSupplyList,
SA = varSA && FA = varFA && VER = VarDDCurr && SupplyType = VarSupplyType
),
"SA",
"MCA",
"FA",
"SupplyType",
"VER",
"Service",
"Year",
"Data",
"ID"
)
);
Collect(
tempNetForDisplay,
ShowColumns(
Filter(
VarSupplyList,
SA = varSA && FA = varFA && VER = VarDDPrior && SupplyType = VarSupplyType
),
"SA",
"MCA",
"FA",
"SupplyType",
"VER",
"Service",
"Year",
"Data",
"ID"
)
)
Hi @WarrenBelz ,
Thanks for checking. I decided to do away with setting the datasource table name as a variable and hardcode it. Since I have a lot of tables, I had to write a long switch statement. It wasn't my 1st choice but it works fine now. The downside to this is repetitive code since only the table name is really changing. Thanks for your suggestion about setting the table as a global variable or creating a collection. Unless I misinterpreted, it would mean I'd have to store the entire table and didn't want to do that because the tables are huge.
Hi @Thrive ,
Just checking if you got the result you were looking for on this thread. Happy to help further if not.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
Hi @Thrive ,
If you are going to store a Table, make a Collection, not set a Variable (you can store Values and Records in those). I am actually surprised the code works at all.
If you have colSupplyList (you did not say how you set that Variable), your code should work fine if those are Global Variables you are filtering on, however your last comment is a bit confusing, you are starting with a Table and then setting the same item to a single Value - these will be incompatible types anyway.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @WarrenBelz ,
VarSupplyList is a context variable. I want to dynamically switch datasources based on a toggle.
If the toggle control it on (true), the datasource is the test table, otherwise it is regular table.
varSA and varFA are global variables and they show as correct values.
Does Collect or ClearCollect not work with variables for datasources??? So I created another test button to troubleshoot the code further. Instead of switching the context variable conditionally for dynamic datasource, I set the context variable to just the test table. Still pulling the wrong # of records. Then, I hardcoded the table in the collect function and only then does it work.
UpdateContext({VarSupplyType: "NET_NEW"});
If(toggle1.value = true,
UpdateContext({VarSupplyList: 'Supply Test'}),
UpdateContext({VarSupplyList: 'Supply'})
)
Hi @Thrive ,
Two things I spotted here
@WarrenBelz , edited post to include code
Hi @Thrive ,
You might supply some code here (in Text) of your ClearCollect.
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473