I have a custom button that I want to validate based on the value of a Person field. The button works as desired when the domain in the Person field matches 'ourcompany.com'. But when the button is clicked and the Person field has a domain value other than 'ourcompany.com', the error returned is "fd.field(...).value.includes is not a function'. I was looking for a simple solution and probably I need to try a split or some other technique. I have [looked at this post](Source: Filtration by emails with certain domain) for initial ideas for domain var options but I didn't get too far there. Sometimes I get good ideas from posts outside of Forms Designer.
Does anyone else have a good idea for this task? Thanks!
fd.spBeforeSave(function() {
var currentVolunteer = fd.field('volunteer').value;
function checkForStaff() {
if (fd.field('volunteer').value.includes('ourcompany.com')) {
// Status Volunteer
fd.field('_Status').value = 'Staff Has';
fd.field('projectstatus').value = 'To Staff';
} else {
// Status Staff
fd.field('_Status').value = 'Volunteer Has';
fd.field('projectstatus').value = 'To Volunteer';
}
}
// Calling checkForStaff on form loading
checkForStaff();
});
return fd.save();