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 / SharePoint List Form E...
Power Apps
Unanswered

SharePoint List Form Event Sequence

(2) ShareShare
ReportReport
Posted on by 765 Super User 2024 Season 1

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.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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. 

  • sperry1625 Profile Picture
    765 Super User 2024 Season 1 on at

    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. 

  • sperry1625 Profile Picture
    765 Super User 2024 Season 1 on at

    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.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

  • sperry1625 Profile Picture
    765 Super User 2024 Season 1 on at

    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.

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

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 421 Most Valuable Professional

#2
11manish Profile Picture

11manish 153 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 116 Super User 2026 Season 2

Last 30 days Overall leaderboard