cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sperry1625
Super User
Super User

SharePoint List Form Event Sequence

Does anyone know if the event firing sequence for a SharePoint List form is documented somewhere? What I am looking for is what comes first, OnVisible() for the screen, OnNew() for SharePointIntegration, etc.

 

I am having issues, even in the IDE, where everything is fine then all of a sudden it thinks a variable is a different type than it is. The only thing I can think of is the order or when variables are created and what types it thinks it is.  I have resolved some of this be commenting out references to the variable in other locations and the error goes away.  But it does come back.  Each time, how I resolve it, changes.  I am ready to scream!  I don't use my variables for different purposes!

 

Any help would be appreciated.

 

Thanks.

Regards,

-S

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.

5 REPLIES 5
RandyHayes
Super User
Super User

@sperry1625 

Make sure you are actually assigning the EXACT same type to each variable reference.  Any changes in how PowerApps interprets your variables will cause unpredictable results. 

Normally, the designer will alter you to these issues with either errors or a warning (depending on the severity of the change).

 

If you can avoid the variables, that is best.  If not, then review all the places where you set it and ensure you are actually setting to the exact type in each case.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Here are the three ways I use this variable:

Set( gblRecord, Defaults( 'My List' ) );
// or
Set( gblRecord, LookUp( 'My List', 'Key'.Id = SharePointIntegration.SelectedListItemID ) );
// or
Patch( gblRecord, frmMyForm.Updates );

I don't think any of these should cause what I am seeing. 

Regards,

-S

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.

sperry1625
Super User
Super User

Added a little debug code to my form.

I added 

Set( dbgTrace, dbgTrace & "Module->Event()" & Char(13) );

to the beginning of each event.

With a little debug testing the event firing sequence is as follows:

For First time Run after Publish for viewing a list item

  1. App->OnStart()
  2. Screen->OnHidden()
  3. Screen->OnVisible()
  4. SharePointIntegration->OnView()

#2 & 3 are confusing. I wouldn't think Hidden would show at all. Even stranger is OnHidden() doesn't seem to be called under any other circumstances.

If I close the form and just view another list item the only event fired is OnView().

I have 4 forms, each pair goes to a list. Each form pair has a master and secondary.  The OnReset() of the master resets the secondary.  When I select Cancel in the form the reset events fire as follows

  1. frmMaster1->OnReset()
  2. frmMaster2->OnReset()
  3. frmSecondary1->OnReset()
  4. frmSecondary2->OnReset()

My code does

ResetForm( frmMaster1 );
ResetForm( frmMaster2 );

Strange how the resets for the secondaries come after both masters are reset.

Added some additional details by adding 

Set( dbgTrace, dbgTrace & "Module->Event( end )" & Char(13) );

at the end of each event. I also added "( begin )" to the start.  The sequence is as follows:

  1. App->OnStart( begin )
  2. Screen->OnHidden( begin )
  3. Screen->OnHidden( end )
  4. Screen->OnVisible( begin )
  5. SPI->OnView( begin )
  6. SPI->OnView( end )
  7. Screen->OnVisible( end )

The sequence is different if I select Edit Item from the view:

  1. App->OnStart( begin )
  2. Screen->OnHidden( begin )
  3. Screen->OnHidden( end )
  4. Screen->OnVisible( begin )
  5. Screen->OnVisible( end )
  6. SPI->OnEdit( begin )
  7. SPI->OnEdit( end )

Notice the OnEdit() occurs after OnVisible() is completed instead of while it is executing.

 

Hope this helps someone.  I have to determine how this impacts my app.

Regards,

-S

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.

RandyHayes
Super User
Super User

@sperry1625 

I hate to say it but I suspect you are overanalyzing a little bit on this.  PowerApps is not quite like a programming environment where order of events is quite that important.  PowerApps works from reference, so usually it is pretty basic as to when and where to do things. Looking at this against your setting of the variable, the order of events has no impact.

 

But, looking at your formulas for your glbRecord, I see an issue (or potential):

   Set( gblRecord, LookUp( 'My List', 'Key'.Id = SharePointIntegration.SelectedListItemID ) );

My question is, is 'My List' the list that you are customizing the forms in or is that another list?

Or am I to read that as you have a Lookup column in 'My List' that points back to the list that you are customizing?

Also, the last one where you set the glbRecord to MyForm.Updates - are you following my video on this?  If so, I am assuming that is in the OnSuccess of the form, and it should be Set(glbRecord, MyForm.LastSubmit) - without that alteration, your record will be missing items that can also cause an issue with the variable signature.

 

ALSO...this is a key point.  The method of setting a variable like this based on the signature of a form and a datasource and defaults will give you headaches if you are also altering your list columns.  PowerApps has to re-evaluate the signatures of variables all the time and it does so based on a fairly complex process.  Sometimes EditForms and even Galleries can "ghost" their signature (prior signature) and when you make a change it totally confuses PowerApps designer.  USUALLY, the solution to that is to just save and close the app and then open again and the ghosts have departed.  This can drive you nuts if you are actually trying to troubleshoot.  The method usually goes that someone spends hours trying to figure it out...gets tired...saves and closes...comes back next day and it appears that everything is now okay.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

You are probably correct, I am over analyzing.  But still having the issue.

To clarify what I am doing...

I have two lists, the one I am customizing (List1) and a second "Detail" list (List2).  List2 has a lookup column back to List1.

List1

  • ID
  • Type (Choice)
  • Description (Text)
  • Attachments

List2

  • ID
  • List1 (Lookup List1)
  • DataType (Choice)
  • TypeDetail1
  • TypeDetail2

The user selects a Type from List1. That selection will filter available selections from List2.DataType. Selection of List2.DataType determines what fields in List2 are required. The order of data entry is:

  • List1.Type
  • List2.DataType
  • List1.Description
  • List1.Attachments
  • List2.(Required Fields)

Due to data entry order I have 4 forms. Form 1 only contains List1.Type. Form 2 only contains List2.DataType. Form 3 contains the rest of the List1 columns. Form 4 contains the rest of the List 2 columns. The app screen is wide, two columns of cards.  The left side of the screen has Forms 1 - 3 and the right side has Form 4. The cards in Form 4 are Shown/Hidden based on what the user selects for List2.DataType. This also means that what fields are required change based on that as well. As the user changes the DataType it's OnChange event sets a variable that the Form 4 cards Visible property keys off of. Then the Required property is set to true if the card is visible. I hope this is clear so far.

I use the method you described in your video to make this work.  I have two globals, gblList1 and gblList2. For SPI.OnNew() these globals are set to the Defaults() for their respective source list. For OnView gblList1 is set to SPI.Selected and I do a LookUp for the List2 data.

Set( gblList1, SharePointIntegration.Selected );
Set( gblList2, LookUp( 'List2', 'List1'.Id = SharePointIntegration.SelectedListItemID );

I then do ViewForm on Forms 3 and Forms 4, as they are the Master forms. I have not gotten to OnEdit yet, so no code there.

For 1 and Form 2 Items property is set to the Globals, gblList1 and gblList2 respectively.

The Items property for Form 3 and 4 are:

// Form 3 Item property (List 1 Master)
Patch( gblList1, If( IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected), First([@'List1']), SharePointIntegration.Selected), frm1.Updates )

// Form 4 Item property (List 2 Master)
Patch( gblList2, If( IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected), First([@'List2']), LookUp( 'List2', 'List1'.Id = SharePointIntegration.SelectedListItemID ) ), frm2.Updates )

I am currently not doing anything in the OnSuccess of the forms.

Form 1 has 1 Card, a Combo Box. That cards default is set to gblList1.Type. Form 2 has 1 Card, a Combo Box. That cards default is gblList2.DataType.

The Save for these lists perform manual validations. It does this by checking the Valid property of the two master forms.  If those are good it does a SubmitForm for Form 3 (List 1) then a SubmitForm for Form 4 (List 2).

If a form is not valid a global variable is set that indicates validation errors. This shows all of the Error labels in the controls. Then as each field is corrected, and the individual cards becomes valid, that cards error label is hidden.  If all succeeds, I do a RequestHide().

Creation of new list entries in both lists works great.

Viewing is inconsistent. After loading the list item the first time I can get "Getting your data..." for Form 1. But if I close the form and reopen it loads properly. Since the visibility of Form 4 cards is done in the OnChange for Form 1 Combo, sometimes loading the data triggers the OnChange, other times it doesn't.  There is an inconsistency here, or something is being/not being initialized, set in certain scenarios.  I am spending way to much time tracking this down.  Not sure what I am doing wrong.

Insights would be appreciated.

Thank you.

Regards,

-S

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.

Helpful resources

Announcements

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Top Solution Authors
Top Kudoed Authors
Users online (6,680)