How to compare two people picker fields on the form

  • 29 August 2017
  • 5 replies
  • 7 views

Badge +5

How to compare people picker fields on the form?

For example if people picker1 is equal to people picker 2 then make field 2  mandatory ( field 2  mandatory rule written on the form).

Thanks in Advance!


5 replies

Badge +16

Add a rule on field 2 as follows:

ensure you use Named Controls (in example above PP1 and PP2 are the named controls of my two people picker fields)

Userlevel 5
Badge +14

equals() compares just strings and is not reliable on people picker controls - How to comapre two people picker controls? 

I recommend to use dedicated userEquals()

Badge +16

oh well it seemed to work fine when I just tested it.

Badge +8

I believe you should use this function userProfileLookup() in the same equal() function above to get the display name string then it will work 

 userProfileLookup("domainlogin", "InternalPropertyName") 

It will be something like this

equal(userProfileLookup(pp1, "PreferredName"), userProfileLookup(pp2, "PreferredName"))

Userlevel 5
Badge +14

1. user's display name is not unique user's identifier. you can have several users with the same display name and different logins, and vice versa single user might have several difference accounts with the same display name.

2. userProfileLookup() works only on SP Server and above editions.

Reply