I have been wrestling with trying to update a collection. Let me describe the problem I am trying to solve.
I have a SharePoint list that has one record corresponding to some buttons that I will use in various Power Apps. Based on user shared access to other Power Apps - each button corresponds to a different app - I want to update NOT THE LIST but a collection created from the list. Why? Because multiple logons for the same or differnt apps that use the list could run at the same time.
Here's what I do:
In the list and col1 and col2, the IDs all start at 1 and increase by 1 for all rows, so the ID matches the sequence array. There is also another column for the list and collections called ButtonID which is an integer that corresponds to the ID (but is just a number column with 0 decimal places). The reason for the sequence, I thought, was that in the ForAll I could by trimming the first row of the array it would always match the collection row in ForAll. Apparantly that works as in testing I create an array row containng the sequence number and buttonid and they match.
Here is then what I try to do:
ForAll(col1,
Patch(col2, LookUp(col2,ThisRecord.Title=Title, {UserOK:TestPermissions.Run(varUser,'App ID').result}));
Remove(colSeq,First(colSeq))
)
The Power Automate is a flow that tests each app ID passed to it (in the SharePoint list and collections) and returns a "Yes" or "No" text to indicate if the user has shared permissions for that app. I can look at the run history for that flow and see that it is successful and returns the desired value for each row in the list. But the collection never gets updated.
I have tried other values in LookUp() all of which were equally unsuccessful, such as ID=ID or Title=Title or ButtonID=ButtonID. I thought ID=First(colSeq).Value would be the thing I actually want but get a type mismatch of Number = Table.
Why do this? I want a gallery to have a list of allowable buttons displayed (along with other data), so filtering the gallery toonly include UserOK = "Yes" makes this a snap if I can figure out how to update the collection for the gallery.....
I realize I am probably doing something stupod, but what?
To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not. ForAll is a function that returns a table of records based on your iteration table and record schema.
It is more efficient to use the function as intended and will provide better performance.
Also, trying to look at the For All as a ForLoop is causing you to chase your tail trying to make it work like one...as I am guessing you are feeling at this point be trying this and that to deal with so many duplicates of collection tables and trying to index it with another.
My first suggestion beyond that is to modify your flow to accept a list of apps rather than just a single app. The reason for that is, most ALL function in PowerApps accept tables as parameters (ie. Patch in this case). If you have a flow that only handles a single record, then you are forced to use the ForAll backward and then the flow has to be instantiated over and over again. This is excessive use of your flows and also a performance hog!
Not entirely understanding your source data and the need for sequences and ID's that match the existing ID, but without that your formula can be changed to:
ClearCollect(colAppList,
ForAll(SharePointList,
{
Title: Title,
'App ID': 'App ID',
UserOK: TestPermissions.Run(varUser,'App ID').result
}
)
)
This would provide a collection (in memory database table) of the list apps and the permissions for the users.
If you are not planning to alter the records in memory in your app, then you can skip the collection and just assign to a variable:
Set(glbAppList,
ForAll(SharePointList,
{
Title: Title,
'App ID': 'App ID',
UserOK: TestPermissions.Run(varUser,'App ID').result
}
)
)
I hope this is helpful for you.
A lot to parse but thanks and I will advise on progress or failures.
Question: in the Set(gblAppList,....) sugesstion, that should result in an array, right? I still have the problem of using the results to filter the gallery.
Question: what exactly do you mean by "backwards" use of ForAll? Am I incorrect to believe that as I have used it, it iterates though col1 (which is identical to col2) but the Patch operates on col2 as a corresponding row? I know I can't Patcvh col1 in the ForAll which is why I duplicated it in col2.
When you say array...there really is not that in PowerApps...it is a table. And so yes, glbAppList would be a table. Tables can be in variables. Those tables can be used on any component that needs a table (like your gallery).
Oh the ForAll - one of my favorite functions in PowerApps (when used properly) as it is the most powerful data tools in the arsenal of functions!
ForAll is a function that returns a table. The structure is ForAll(table, {record definition}) So the table is the table that ForAll will iterate over, the record definition defines what the schema of the returned table will be.
Example:
ForAll(Sequence(10), {MyCol: Value + 5})
In the above, the table to iterate over is a table (returned from Sequence) that has a single column called Value. We want our ForAll to iterate over that and create a table with records that have a MyCol column that contains the Value of the Sequence-returned table plus 5.
One very important thing to keep in mind is that if you do NOT specify a record structure, PowerApps will automatically create a Value column.
So, for example: ["a", "b", "c"] will produce a table with a single column called Value (because nothing was specified. It is equivalent to: Table({Value: "a"}, {Value: "b"}, {Value: "c"}) (but you can see the shorthand is quicker if you are good with a Value column)
Likewise, if you use a ForAll with no record definition - ex: ForAll(["a", "b", "c"], "X") This will produce a table with three rows that have a single column called Value with a value of "X"
Why I say that is...when you use the ForAll backward, it is still creating a table, you just are wasting the output of it.
It's like putting a 2+2 in an action formula...PowerApps will still evaluate it to 4, but since you are not assigning it or using it...it is wasted.
When trying to use ForAll as a ForLoop (which it will mimic because it technically iterates over things), you will quickly come to hate it because that is not what it was designed for. You cannot do things in it like in a ForLoop because (hopefully now obvious) you can't impact the source iterator while you iterate over it. Plus, if you are putting "statements" in your ForAll rather than record information, then each is returning values that are being added to a Value column in the ForAll record...and then wasted! This ALL contributes to added and unnecessary overhead in your app.
I just wish that they would modify the docs on PowerApps to NOT have examples that use the ForAll backward! It gives people the WRONG impression on how to use it. And since many developers flock to PowerApps with the developer mindset...the first thing they are looking for is "where's the for loop function?" - They find the ForAll and think "That's it!". Quickly things go wrong!
But the biggest obstacle is the collections and the duplication of collections. Keep in mind that each one is just a copy of the data over and over. There is no need for all that overhead in the app.
A collection should ONLY be used in scenarios where you need to add/remove or update records in a table in memory. (or if you are building an offline app...where you do need in-memory database ability).
You'll see that the last formula I provided uses no collections. It produces a table of records (you can see the records structure in the ForAll) into a table that is stored in a variable (because it most likely does not need to be add/remove/updated later on in the app).
Hopefully this all makes sense and is helpful for you. I can go on and on about ForAll usage and Collection usage in PowerApps because they are probably one of the top two things that are misused in the platform and contribute to people doing much more work than is necessary in their design process.
Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs. Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.
Super Users – 2023 Season 1 We are excited to kick off the Power Users Super User Program for 2023 - Season 1. The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts. Super User Season 1 | Contributions July 1, 2022 – December 31, 2022 Super User Season 2 | Contributions January 1, 2023 – June 30, 2023 Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile. Power Apps Power Automate Power Virtual Agents Power Pages Pstork1* Pstork1* Pstork1* OliverRodrigues BCBuizer Expiscornovus* Expiscornovus* ragavanrajan AhmedSalih grantjenkins renatoromao Mira_Ghaly* Mira_Ghaly* Sundeep_Malik* Sundeep_Malik* SudeepGhatakNZ* SudeepGhatakNZ* StretchFredrik* StretchFredrik* 365-Assist* 365-Assist* cha_cha ekarim2020 timl Hardesh15 iAm_ManCat annajhaveri SebS Rhiassuring LaurensM abm TheRobRush Ankesh_49 WiZey lbendlin Nogueira1306 Kaif_Siddique victorcp RobElliott dpoggemann srduval SBax CFernandes Roverandom schwibach Akser CraigStewart PowerRanger MichaelAnnis subsguts David_MA EricRegnier edgonzales zmansuri GeorgiosG ChrisPiasecki ryule AmDev fchopo phipps0218 tom_riha theapurva takolota Akash17 momlo BCLS776 Shuvam-rpa rampprakash ScottShearer Rusk ChristianAbata cchannon Koen5 a33ik Heartholme AaronKnox Matren Alex_10 Jeff_Thorpe poweractivate Ramole DianaBirkelbach DavidZoon AJ_Z PriyankaGeethik BrianS StalinPonnusamy HamidBee CNT Anonymous_Hippo Anchov KeithAtherton alaabitar Tolu_Victor KRider sperry1625 IPC_ahaas zuurg rubin_boer cwebb365 Dorrinda G1124 Gabibalaban Manan-Malhotra jcfDaniel WarrenBelz Waegemma If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances. Once they are received the list will be updated.
We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida. Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more. Register today: https://www.powerplatformconf.com/
We are excited to share the ‘Power Platform Communities Front Door’ experience with you! Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well. Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities. Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform. Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.
Welcome! Congratulations on joining the Microsoft Power Apps community! You are now a part of a vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun! Now that you are a member, you can enjoy the following resources: The Microsoft Power Apps Community Forums If you are looking for support with any part of Microsoft Power Apps, our forums are the place to go. They are titled "Get Help with Microsoft Power Apps " and there you will find thousands of technical professionals with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Apps community forums! Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered! Microsoft Power Apps IdeasDo you have an idea to improve the Microsoft Power Apps experience, or a feature request for future product updates? Then the "Power Apps Ideas" section is where you can contribute your suggestions and vote for ideas posted by other community members. We constantly look to the most voted Ideas when planning updates, so your suggestions and votes will always make a difference. Community Blog & NewsOver the years, more than 600 Power Apps Community Blog Articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on building Power Apps. On the Power Apps Community Blog, read the latest Power Apps related posts from our community blog authors around the world. Let us know if you would like to become an author and contribute your own writing — everything Power Apps related is welcome! Power Apps Samples, Learning and Videos GalleriesOur galleries have a little bit of everything to do with Power Apps. Our galleries are great for finding inspiration for your next app or component. You can view, comment and kudo the apps and component gallery to see what others have created! Or share Power Apps that you have created with other Power Apps enthusiasts. Along with all of that awesome content, there is the Power Apps Community Video & MBAS gallery where you can watch tutorials and demos by Microsoft staff, partners, and community gurus in our community video gallery. Again, we are excited to welcome you to the Microsoft Power Apps community family! Whether you are brand new to the world of process automation or you are a seasoned Power Apps veteran. Our goal is to shape the community to be your ‘go to’ for support, networking, education, inspiration and encouragement as we enjoy this adventure together! Let us know in the Community Feedback if you have any questions or comments about your community experience.To learn more about the community and your account be sure to visit our Community Support Area boards to learn more! We look forward to seeing you in the Power Apps Community!The Power Apps Team
User | Count |
---|---|
138 | |
98 | |
88 | |
74 | |
59 |
User | Count |
---|---|
235 | |
167 | |
112 | |
93 | |
90 |