Compare People Picker Field Names

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
enillrae
Posts: 17
Joined: Mon May 29, 2017

06 May 2020

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;
});

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

07 May 2020

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 4887 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;
});

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests