Hello all,
I'm trying to make a custom form for my SharePoint list, which for planning/use purposes has two different types of items, "Internal Events" and "Pre-Arrival Initiatives". They are both primarily viewed via Calendar views in SharePoint, and each have very different column choices. Thus I was looking to make each have it's own "View" form screen. "Edit" and "New" will likely only be done by me, so I just have all columns on the same screen for these. To have something to point the code at for differentiating the two types, I have a choice column named FormType with two choices, the exact names of each used above.
Using this article, I established separate screens for View, New, and Edit. I duplicated the Screen and Form for View, and renamed it. Then for the OnView action, I used this code:
Set(SharePointFormMode, "ShowForm");
If(SharePointIntegration.Selected.FormType.Value = "Internal Events", ViewForm(SharePointForm1),SharePointIntegration.Selected.FormType.Value = "Pre-Arrival Initiatives", ViewForm(SharePointForm2));
If(SharePointIntegration.Selected.FormType.Value = "Internal Events", Navigate(FormScreen1, ScreenTransition.None),SharePointIntegration.Selected.FormType.Value = "Pre-Arrival Initiatives", Navigate(FormScreen2))
This sort-of works, with 90% of the time displaying the form type that you last viewed, only correcting when you leave and come back again. For example, clicking an Internal Event shows the Internal Event View form, then exiting and clicking a Pre-Arrival Initiative shows it with an Internal Event View form, corrected when you exit the item and enter back into it. I'm at a loss at this point, unfortunately all I know on PowerApps is self taught from forums (I work in Hospitality, ha).
Any thoughts on what might be wrong with the code, or an alternate way to recognize the item's value in the FormType column? Should I place this same code elsewhere? Can I put a sort-of "Loaded incorrectly? Click here!" refresh button on the bottom of the form at least? Any thoughts or ideas are greatly, greatly appreciated!!