cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TroGun18
Level: Powered On

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
Community Support Team
Community Support Team

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
RakeshPandey
Level: Powered On

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)

KKrishnapriya
Level: Powered On

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 !!

 

 

TroGun18
Level: Powered On

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)

 

 

RakeshPandey
Level: Powered On

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.

TroGun18
Level: Powered On

Re: Disable save button if 2 conditions are equal

Hi @RakeshPandey 

This is the error:

image.png

 

 

 

RakeshPandey
Level: Powered On

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...

Community Support Team
Community Support Team

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.
TroGun18
Level: Powered On

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? 

Community Support Team
Community Support Team

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,600)