I have tried many combinations of setting a variable at the App OnStart level. Essentially I want to use ModelDrivenFormIntegration to say if either of two fields is "Yes" (OptionSetValue) that a button and a text field should be disabled. For simplicity sake, we'll say Field1 and Field2 are the two fields, Button1, and Input1 are the controls to be enabled/disabled. All of the following failed:
Set Inputs DisplayMode to variable, set DisplayMode based on logic:
Button1.DisplayMode & Input1.DisplayMode = varEnabled
App.OnStart =
Set(
varEnabled,
If(
ModelDrivenFormIntegtation.Item.Field1 = 'Yes' Or
ModelDrivenFormIntegration.Item.Field2 = 'Yes'
),
DisplayMode.Disabled,
DisplayMode.Enabled
)
)
Set variable to true/false, and do an simple If statement on the DisplayMode of each
App.OnStart =
Set(
varEnabled,
If(
ModelDrivenFormIntegtation.Item.Field1 = 'Yes' Or
ModelDrivenFormIntegration.Item.Field2 = 'Yes'
),
true,
false
)
)
Button1.DisplayMode = If(varEnabled, DisplayMode.Disabled, DisplayMode.Edit)
Label1.DisplayMode = If(varEnabled, DisplayMode.Disabled, DisplayMode.Edit)
Then to make sure I wasn't going crazy (or that App.OnStart and ModelDrivenFormIntegration weren't loading at times to create conflict), I created three labels, and did the following:
App.OnStart =
Set(
varEnabled,
If(
ModelDrivenFormIntegtation.Item.Field1 = 'Yes' Or
ModelDrivenFormIntegration.Item.Field2 = 'Yes'
),
false,
true
)
);
Set(
varLabel1,
If(ModelDrivenFormIntegration.Item.Field1 = 'Yes', false, true)
);
Set(
varLabel2,
If(ModelDrivenFormIntegration.Item.Field2 = 'Yes', false, true)
);
Label1.Text = varLabel1
Label2.Text = varLabel2
Label3.Text = varEnabled
The result was Label1 = false, Label2 = false, Label3 = true.
I have tried every combo I can think of, but I cannot figure it out. I have also replace the inline Or with the Or() inside of the If statement. I have also tried nesting the Set() statement within the If statement. It all leads to the same result of it not working as I would expect it to work. The only way I have gotten it to work is if I put the exact same If statement from my first example directly into the DisplayMode of the various controls. I can use that workaround, but I was wanting to use this variable throughout and feel like this should work.

Report
All responses (
Answers (