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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,023)