Am I doing this right? I change the people field name to my field name but it still isn't redirecting the form?
if (item) {
//first, get the current user
var user;
// return Promise
return web.currentUser.get()
.then(function(u) {
user = u;
return item.get();
})
.then(function(item) {
//if field People contains current user's ID
if(item.Director && item.Director.indexOf(user.Id) >= 0){
//return ID of a Form Set
return 'ca9f17f4-dbf9-416d-8e68-9257cd35e7cd';
}
});
}
To get the value of the People Picker field, you need to add Id to its Internal name. So the code will be the following:
if (item) {
//first, get the current user
var user;
// return Promise
return web.currentUser.get()
.then(function(u) {
user = u;
return item.get();
})
.then(function(item) {
//if field People contains current user's ID
if(item.DirectorId && item.DirectorId.indexOf(user.Id) >= 0){
//return ID of a Form Set
return 'ca9f17f4-dbf9-416d-8e68-9257cd35e7cd';
}
});
}