good day,
how can i verify current user opened form with a multiple person field? i tried, and can get emails of multiple person field, how to compare them with current user ?
//this part work
var daesTest = [];
if (fd.field('User').value.forEach) {
fd.field('User').value?.forEach(function (Value) {
const Email = Value.EntityData.Email ?? Value.EntityData.Email //?? getUserID(Value.EntityData.Email);
daesTest.push(Email);
console.log('daesTest push Email:', Email);
//this part work
});
/// this part doesn't work
if (daesTest.indexOf(_spPageContextInfo.userEmail)){
console.log('===========User present in UserTO================')
$('.delegatebtn').show()
} else {
$('.delegatebtn').hide()
}
}
function checkForCurrentUser(){
//check every user in field
for(var i = 0; i < fd.field('bgbr').value.length; i++){
var person = fd.field('bgbr').value[i];
//if user matches
if(person.EntityData.Email == _spPageContextInfo.userEmail){
return true;
}
}
//after checking, if not found
return false;
}
if(checkForCurrentUser()){
alert('Found!');
}
else{
alert('Not found');
}