Page 1 of 1

Compare People Picker Field Names

Posted: 06 May 2020
by enillrae
Hi,

I have a form with two people picker fields in which the two fields cannot have the same person chosen. How do I compare the values in the two fields, and if they are the same alert the user on submit.

See my code below, but I keep getting an error:

fd.onsubmit(function () {
if (fd.field('Owner').value() == fd.field('Checker').value()){
alert('Owner cannot be the same as Checker'');
return false;
}
return true;
});

Re: Compare People Picker Field Names

Posted: 07 May 2020
by mnikitina
Hello enillrae,

If the field Template is set to Default, you can use the below code to get the value of two people picker fields and compare them.
template.PNG
template.PNG (6.83 KiB) Viewed 2783 times

Code: Select all

fd.onsubmit(function () {
if (fd.field('Owner').value()[0].Key == fd.field('Checker').value()[0].Key){
alert('Owner cannot be the same as Checker'');
return false;
}
return true;
});