cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Faribeiro
Helper I
Helper I

Onstart displaymode button

Hello all

 

I want to enable(displaymode) a button onstart based on internet available. If internet available then button enabled if not internet then grey out button.

I have tried code below but doesnt work. Having or not having internet, button is always enabled.

 

If(Connection.Connected,Button2.DisplayMode.Edit,Button2.DisplayMode.Disabled);

 

on button2 Displaymode properties it is left in blank.

 

Second question is also related to onstart.

 

I have a dropdown with months of the year. I want onstart dropdown be setup accord to current month.

I tried code below but no success.

Dropdown1.Selected.Value = Text(Today(), "[$-en-US]mmmm") 

 

Thanks in advance for any help

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
FabianAckeret
Super User
Super User

Hi @Faribeiro 

 

Your formula is basically correct. However, you can't set values directly in other fields. You'd need to set variables and use those variables in the corresponding properties.

 

So, your first formula:

 

// incorrect
If(Connection.Connected,Button2.DisplayMode.Edit,Button2.DisplayMode.Disabled);

// correct
If(Connection.Connected,Set(gblDisplayMode,DisplayMode.Edit),Set(gblDisplayMode,DisplayMode.Disabled))

 

Now you just need to set gblDisplayMode to the Button2.DisplayMode property.

 

Your second question is the same. Set a variable instead of trying to set a value to a different field directly.

 

// incorrect
Dropdown1.Selected.Value = Text(Today(), "[$-en-US]mmmm") 

// correct
Set(gblToday, Text(Today(), "[$-en-US]mmmm")

 

 

and then set the gblToday variable to the Dropdown1.Default property. Alternatively, you can set Text(Today(), "[$-en-US]mmmm") directly to the Dropdown1.Default property.

 

I hope this helps.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

View solution in original post

RandyHayes
Super User
Super User

@Faribeiro 

Consider the following - Instead of setting a variable (very much overused in PowerApps), have your control derive its state from the Connection object.  Set the DisplayMode property of Button1 to the following:

If(Connection.Connected, DisplayMode.Edit, DisplayMode.Disabled)

 

As for the DropDown - you need to set the Default property of that control to what you want.  If it is truly a DropDown, you cannot select multiple items, so default is the only property you need to deal with.  Default formula:

Text(Today(), "mmmm")

 

No variables needed for either.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
FabianAckeret
Super User
Super User

Hi @Faribeiro 

 

Your formula is basically correct. However, you can't set values directly in other fields. You'd need to set variables and use those variables in the corresponding properties.

 

So, your first formula:

 

// incorrect
If(Connection.Connected,Button2.DisplayMode.Edit,Button2.DisplayMode.Disabled);

// correct
If(Connection.Connected,Set(gblDisplayMode,DisplayMode.Edit),Set(gblDisplayMode,DisplayMode.Disabled))

 

Now you just need to set gblDisplayMode to the Button2.DisplayMode property.

 

Your second question is the same. Set a variable instead of trying to set a value to a different field directly.

 

// incorrect
Dropdown1.Selected.Value = Text(Today(), "[$-en-US]mmmm") 

// correct
Set(gblToday, Text(Today(), "[$-en-US]mmmm")

 

 

and then set the gblToday variable to the Dropdown1.Default property. Alternatively, you can set Text(Today(), "[$-en-US]mmmm") directly to the Dropdown1.Default property.

 

I hope this helps.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

View solution in original post

RandyHayes
Super User
Super User

@Faribeiro 

Consider the following - Instead of setting a variable (very much overused in PowerApps), have your control derive its state from the Connection object.  Set the DisplayMode property of Button1 to the following:

If(Connection.Connected, DisplayMode.Edit, DisplayMode.Disabled)

 

As for the DropDown - you need to set the Default property of that control to what you want.  If it is truly a DropDown, you cannot select multiple items, so default is the only property you need to deal with.  Default formula:

Text(Today(), "mmmm")

 

No variables needed for either.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Faribeiro
Helper I
Helper I

tks Isabasu and RandyHayes.....much appreciate for the prompt answer. Both did work great!!!!!

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,006)