cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Disable save button if 2 conditions are equal

Hi,

 

I would like to disable a save button if 2 dropdown values are the same (for example "Requestor" & "Approver").

Preferrably I would like an error message to appear rather than the button not visible if the 2 conditions are the same value.

 

Does anyone know how to do this? 

Much appreciated 🙂

 

Regards,

Trond

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Disable save button if 2 conditions are equal

Hi @TroGun18 ,

If you want to compare the "Approver" with the current login user, please consider modify above formula as below:

Set the DisplayMode property of the "Save" button to following:

If(
    ApproverDropdown.Selected.DisplayName = User().FullName,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

or

If(
    ApproverDropdown.Selected.Email = User().Email,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

Note: I assume that the Approver column is a Person type column in your SP List data source.

or

If(
    ApproverDropdown.Selected.Email <> User().Email,
    DisplayMode.Edit,
    DisplayMode.Disabled
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Highlighted
Helper I
Helper I

Re: Disable save button if 2 conditions are equal

@TroGun18 you can try below formula on DisplayMode of the Button.

If(Dropdown1.Selected.Value=Dropdown3.Selected.Value,DisplayMode.View,DisplayMode.Edit)

Highlighted
Frequent Visitor

Re: Disable save button if 2 conditions are equal

Hi @TroGun18 ,

 

If you are using Model Driven App, you can try using Business rules to show error Message.

 

Thanks !!

 

 

Highlighted
Helper III
Helper III

Re: Disable save button if 2 conditions are equal

Hi @RakeshPandey ,

image.png

 

Thanks for the quick reply. Unfortunately I receive an error on this formulae: 

If(DataCardValue7.Value=DataCardValue2.Value,DisplayMode.View,DisplayMode.Edit)

 

 

Highlighted
Helper I
Helper I

Re: Disable save button if 2 conditions are equal

@TroGun18  can you provide the screen shot of the error. Because the one which you have attached is not clear.

Highlighted
Helper III
Helper III

Re: Disable save button if 2 conditions are equal

Hi @RakeshPandey 

This is the error:

image.png

 

 

 

Highlighted
Helper I
Helper I

Re: Disable save button if 2 conditions are equal

@TroGun18 Error says that unable to recognise the Datacard. You can remove the datacards and then add it back in to see if the error still happens. You can refer below threads for more details regarding this error.

https://powerusers.microsoft.com/t5/General-Discussion/Name-isn-t-valid-This-identifier-isn-t-recogn...

https://powerusers.microsoft.com/t5/General-Discussion/Choice-List-Errors-when-added-to-Form/td-p/18...

Highlighted
Community Support
Community Support

Re: Disable save button if 2 conditions are equal

Hi @TroGun18 ,

Could you please share more details about the formula you typed within the Items property of the Requestor Dropdown box and Approver Dropdown box?

Do you want to compare the selected value within the two Dropdown box?

Which type column in your data source do the two Dropdown box connect to? Person type column in your SP List?

 

Based on the formula you provided, I think there is something wrong with it. Please consider modify your formula as below:

Set the DisplayMode property of the "Save" button to following:

 

If(
    RequestorDropdown.Selected.Value = ApproverDropdown.Selected.Value,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

 

 

If the two Dropdown boxes or ComboBox (Requestor & Approver) connects to Person type column in a SP List, please consider modify above formula as below:

Set the DisplayMode property of the "Save" button to following:

If(
    RequestorDropdown.Selected.DisplayName = ApproverDropdown.Selected.DisplayName,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

Note: I assume that the Items proeprty of Requestor ComboBox and Approver ComboBox has been set to following individually:

 

Choices('YourSPList'.Requestor)
Choices('YourSPList'.Approver)

 

Please consider take a try with above solution, then check if the issue is solved.

 

If the Items property of the Requestor ComboBox and Approver ComboBox has been set to following formula:

 

Distinct(...)

Please modify above formula as below:

 

Set the DisplayMode property of the "Save" button to following:

If(
    RequestorDropdown.Selected.Result = ApproverDropdown.Selected.Result,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

 

If you want an error message to show up rather than disable the "Save" button, I think a Timer control could achieve your needs. Please add a Timer control in your Edit screen, set the Duration property to following:

1000

set the Repeat property and AutoStart property to following:

true

set the OnTimerEnd property to following:

If(
    RequestorDropdown.Selected.DisplayName = ApproverDropdown.Selected.DisplayName,
Notify("The Requestor you selected could not be same as the Approver, please modify it!", NotificationType.Error) )

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper III
Helper III

Re: Disable save button if 2 conditions are equal

Hi @v-xida-msft ,

 

Thanks for the answer :). I think I need to do this differently. Instead of Requestor I need to have the logged in user to NOT be the same as "Approver". Would you know how to do this? 

Highlighted
Community Support
Community Support

Re: Disable save button if 2 conditions are equal

Hi @TroGun18 ,

If you want to compare the "Approver" with the current login user, please consider modify above formula as below:

Set the DisplayMode property of the "Save" button to following:

If(
    ApproverDropdown.Selected.DisplayName = User().FullName,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

or

If(
    ApproverDropdown.Selected.Email = User().Email,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

Note: I assume that the Approver column is a Person type column in your SP List data source.

or

If(
    ApproverDropdown.Selected.Email <> User().Email,
    DisplayMode.Edit,
    DisplayMode.Disabled
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,954)