Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Automatically Executing Code When Opening a Custom SharePoint List Form in PowerApps

(1) ShareShare
ReportReport
Posted on by 14

I have developed a custom form for a SharePoint list. I want to execute some code that essentially rebuilds a collection whenever the form opens.

The code itself is correct because it works perfectly when triggered by a button. However, I would like it to run automatically when the form opens, without needing to use a button.

This would allow the data in the custom form to be displayed correctly every time a user opens it from the SharePoint list.

I have tried the OnStart event, as well as the OnVisible event of the form's screen, but it seems that the code is being ignored.

Any suggestions?

Thank you.

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    146,679 Most Valuable Professional on at
    Automatically Executing Code When Opening a Custom SharePoint List Form in PowerApps
    Hi vigand ,
    The fundamental idea behind an integrated form is a replacement for the "standard" SharePoint form with simple Add/Edit/New functions with the idea that users would simply be opening a record, doing something and then opening another one. It was very inefficient performance-wise to have to open the app every time a user changed records, so the Form is simply hidden and made visible again when the next record was selected, allowing very fast and efficient record management. Consequently OnStart and OnVisible do not run (as they would not in a Canvas App if you simply change the record without leaving the screen).
    There are other reasons I can speculate on (a SharePoint List can be shared with users without any licence) where full Canvas App functionality would not be included (there are other areas as well as this one). 
  • vigand Profile Picture
    14 on at
    Automatically Executing Code When Opening a Custom SharePoint List Form in PowerApps

    Thank you WarrenBelz for your response.

    In essence, regardless of everything, any function I start on the custom form will only work the first time and not on subsequent attempts. Therefore, I imagine that even the idea of inserting a timer when opening the form wouldn’t solve the problem.

    I must say that I expected it to be something structural, but it is quite surprising that it is allowed to build a custom form only to limit it so significantly.
     
    Best regards
     
  • WarrenBelz Profile Picture
    146,679 Most Valuable Professional on at
    Automatically Executing Code When Opening a Custom SharePoint List Form in PowerApps
     
    Hi  vigand ,
    Unfortunately, a fundamental functionality of Integrated SharePoint forms that is designed to enhance performance also impedes functions that need to run automatically. You will notice that the OnCancel and OnSave events have RequestHide() as the last command - essentially hiding the form waiting for the next record to open, then unhiding the form and updating the record according to the SharePointIntegration.Selected value. Although OnStart and any screen OnVisible code will certainly run when the first record is selected, it does not for subsequent records as the form is actually still open. The only way to instigate the code runnning is for the user to refresh their browser between each record.
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,679 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard