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

Button to lock fields

I currently have a button that when clicked, is supposed to lock certain fields on my app from being edited.

 

The OnSelect for the button is:

Set(varLockFields, DisplayMode.Disabled)

 

And then for the fields I want it to be locked, I put "varLockFields" on the DisplayMode setting.

 

It doesn't work for some reason. Any advice?

 

Also, if I want the button to toggle if it's locked or not, how would I do that?

1 ACCEPTED SOLUTION

Accepted Solutions
TheRobRush
Super User
Super User

Ok so what I am getting is that on day 2&3 it should ALWAYS be locked, but on any other day it should be open UNLESS someone clicks the button then it will lock and unlock based on their button press which would go like this

Switch(
    Weekday(Today()),
    2, DisplayMode.Disabled,
    3, DisplayMode.Disabled,
    If(
        IsBlank(varmode),
        DisplayMode.Edit,
        varmode)
)
_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

5 REPLIES 5
TheRobRush
Super User
Super User

I just tested this with a button that has the onselect of 

Switch(varmode,DisplayMode.Disabled,Set(varmode,DisplayMode.Edit),Set(varmode,DisplayMode.Disabled))

and set display mode of a checkbox to varmode

 

worked perfectly

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Thanks for that. It seems like it works.

 

How do I put multiple conditions in the DisplayMode field?

 

I currently have:

If(Or(Weekday(Today())=2, Weekday(Today())=3), DisplayMode.Disabled, DisplayMode.Edit)

 

I thought I could do something like this but it doesn't work:

If(Or(Weekday(Today())=2, Weekday(Today())=3),DisplayMode.Disabled, DisplayMode.Edit);

varmode

TheRobRush
Super User
Super User

Explain to me what it is you want that to do, because in your example you are just saying Display Mode; Second Display Mode. Not OR or If like I assume you intend. Just type out in a regular sentence i want the app to check this then this and do this or this etc

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

So I have fields that are supposed to lock for everybody on Monday and Tuesday, which currently works fine with this line:

 

If(Or(Weekday(Today())=2, Weekday(Today())=3), DisplayMode.Disabled, DisplayMode.Edit)

 

I then have a button where only certain users can click and will lock those same fields manually. You switch line allowed that to work, but when I try to add a second DisplayMode code, I get an error.

TheRobRush
Super User
Super User

Ok so what I am getting is that on day 2&3 it should ALWAYS be locked, but on any other day it should be open UNLESS someone clicks the button then it will lock and unlock based on their button press which would go like this

Switch(
    Weekday(Today()),
    2, DisplayMode.Disabled,
    3, DisplayMode.Disabled,
    If(
        IsBlank(varmode),
        DisplayMode.Edit,
        varmode)
)
_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,641)