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

How do i notify user if two fields in the form have same value?

Hi,

 

I have a form with To and From Office fields in an App recording the movement of mail within the company; both fields are Dropdown controls with the Office values populated into Items (rather than looking up values elsewhere). I want to notify users when the To and From values are the same as they should never be the same.

 

I have played around with a timer to show an error when the values are the same. Problem is I haven't quite figured out how to not show this error when there are blank values in both drowdown controls (which are the default values ). So as soon as the form loads the error message is displayed, I only want this to display if they have selected values other than blank e.g. To=Glasgow, From=Glasgow.

 

This is the formula  I have against the Timers OnTimerEnd variable: If(!IsBlank(DropdownNewSenOffice.SelectedText.Value) = !IsBlank(ReceivingOfficeNew.SelectedText.Value) ||!IsBlank(DataCardValue32.Selected.DisplayName) = !IsBlank(DataCardValue9.Selected.DisplayName),Notify("Please check the form for duplicate values",NotificationType.Error))

 

Any advice on above or alternative solutions would be very welcome

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AnneZC
Helper I
Helper I

Hi @mikiepat 

I have tested this logic out with two text input boxes and it works like I think you want it to.

I have put a formula in the OnChange property of each of the text input boxes rather than using a timer. Then the values will be compared any time one of the values changes.

 

The formula in the OnChange property of TextInput1 is:

 

If(Not(IsBlank(TextInput1.Text)),If(TextInput1.Text=TextInput2.Text,Notify("Values should be different")))

 

and for the OnChange property of TextIput2 it is:

 

If(Not(IsBlank(TextInput2.Text)),If(TextInput1.Text=TextInput2.Text,Notify("Values should be different")))

 

 

View solution in original post

2 REPLIES 2
AnneZC
Helper I
Helper I

Hi @mikiepat 

I have tested this logic out with two text input boxes and it works like I think you want it to.

I have put a formula in the OnChange property of each of the text input boxes rather than using a timer. Then the values will be compared any time one of the values changes.

 

The formula in the OnChange property of TextInput1 is:

 

If(Not(IsBlank(TextInput1.Text)),If(TextInput1.Text=TextInput2.Text,Notify("Values should be different")))

 

and for the OnChange property of TextIput2 it is:

 

If(Not(IsBlank(TextInput2.Text)),If(TextInput1.Text=TextInput2.Text,Notify("Values should be different")))

 

 

View solution in original post

Thanks AnneZC!

That worked a treat! I adapted the above formula to four fields as follows:

 

Dropdown1: If(Not(IsBlank(Dropdown1.Selected.DisplayName)),If(Dropdown1.Selected.DisplayName=Dropdown2.Selected.DisplayName,Notify("Values should be different")))

Dropdown2: If(Not(IsBlank(Dropdown2.Selected.DisplayName)),If(Dropdown2.Selected.DisplayName=Dropdown1.Selected.DisplayName,Notify("Values should be different")))

Dropdown3: If(Not(IsBlank(Dropdown3.Selected.Value)),If(Dropdown3.Selected.Value=Dropdown4.Selected.Value,Notify("Values should be different")))

Dropdown4: If(Not(IsBlank(Dropdown4.Selected.Value)),If(Dropdown4.Selected.Value=Dropdown3.Selected.Value,Notify("Values should be different")))

 

Dropdowns 1 & 2 are people picker dropdowns and Dropdowns 3 & 4 are standard dropdowns

 

thanks

 

Mike

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (27,355)