@KBeale
I'm glad to hear that you were able to make progress!
About when to use OnStart vs StartScreen:
1. OnStart: This formula is executed when the app is first launched, before any screens are shown.
It's typically used to initialize global variables and collections, and fetch data from data sources.
It's also used to perform actions that should only occur once during an app session, for instance, navigating to a specific screen based on parameters passed in the URL.
2. StartScreen: This property determines which screen to show first when the app is launched. It's often set to a static screen, but you can also use it dynamically based on parameters or variables.
Given this, your use of both is appropriate. OnStart is used to initialize varRecord based on the ID parameter, and StartScreen is used to navigate to the correct screen based on the parameters.
In regards to form mode, you can set it on the OnVisible property of the specific screen where the form is located. This way, every time that screen is visited, the form mode is set appropriately. For instance, you might set frmRequestForm's DefaultMode to FormMode.Edit if a parameter is provided, or to FormMode.New otherwise.
Here is a sample formula that you might use in the OnVisible property of the screen where your frmRequestForm is located.
This should set the form to FormMode.Edit if an "ID" parameter is provided, and FormMode.New otherwise.
If(
Not(IsBlank(Param("ID"))),
UpdateContext({ varFormMode: FormMode.Edit }),
UpdateContext({ varFormMode: FormMode.New })
)
Then, in the DefaultMode property of frmRequestForm, you could simply use the varFormMode variable like so:
varFormMode
This way, every time the screen becomes visible, the form mode is set appropriately based on the "ID" parameter.
Please note that UpdateContext is used to create a context variable (varFormMode in this case) that is local to the specific screen. With these kinds of variables, you should not suddenly use the Set function on these kinds of variables later, as Set is only for global variables, and UpdateContext is only for context variables. If you need the variable to be accessible globally across different screens, consider using the Set function instead of UpdateContext.
Consider also using the prefix "glo" for global variables, "var" for context variables (or any naming you want that helps you differentiate the two kinds of variables at a glance).
If you want to use a global variable instead of a context variable, you can use the Set function instead of UpdateContext:
If(
Not(IsBlank(Param("ID"))),
Set(gloFormMode, FormMode.Edit),
Set(gloFormMode, FormMode.New)
)
Then, in the DefaultMode property of frmRequestForm, you could use the gloFormMode variable like so:
gloFormMode
Hope it helps @KBeale