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 / Power Apps Help with C...
Power Apps
Unanswered

Power Apps Help with Consolidation of text

(0) ShareShare
ReportReport
Posted on by 15

OnStart, I currently have a few collections being created. Then, later in the PowerApps, I have additional items being added to the SharePoint lists that the collections come from, so I need to refresh the data and recreate the collections. Is there a way I can put all of my refreshes and clearcollects into a global variable or something to reference? I currently have the same exact code copied each time something is added to the lists. Thank you!

Categories:
I have the same question (0)
  • Hassan_SZ_365 Profile Picture
    542 on at

    Hi @jmaur769 ,

     

    Create a Context Variable with a Function: Use the Set function to create a global variable that holds a function to refresh your data sources and recreate collections. 

     

    Set(
     RefreshAndCollect,
     {
     Run: function() {
     Refresh(DataSource1);
     ClearCollect(Collection1, DataSource1);
     Refresh(DataSource2);
     ClearCollect(Collection2, DataSource2);
     // ... Add additional data sources and collections as needed.
     }
     }
    );
    ​

     

    Invoke the Function: Whenever you need to refresh the data and recreate the collections, you call the Run method of your global variable.

     

    RefreshAndCollect.Run();

     

    OnStart: You can invoke this in the OnStart of the app as well:

    If(
    // Check if the function exists and then call it
    Not(IsEmpty(RefreshAndCollect)),
    RefreshAndCollect.Run()
    );

    After Adding Items: Use the same call after items are added to your SharePoint lists to refresh and collect the data again.

    Please note that while Power Apps does not support the creation of reusable functions in the same way traditional programming languages do, this pattern can emulate that functionality to some extent by encapsulating repetitive logic into a single context variable.

     

    Best Regards,

    Hassan Raza

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard