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 / Issue Getting Correct ...
Power Apps
Unanswered

Issue Getting Correct Variable Value for App OnStart

(0) ShareShare
ReportReport
Posted on by 75

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.

Categories:
I have the same question (0)

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 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard