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.