Hey all, I've created a roombooking system where I have a field "Verantwortlich" (=responsible Person) which I want to check against the current user to make sure that only the person who created the item or is responsible for the item can delete it.
It worked before but now suddenly it stopped working and I always get "undefined" from the following lines:
var value = fd.field('Verantwortlich').value.email;
console.log("VerantwortlichMail: " + value);
My whole code:
pnp.sp.web.lists.getByTitle('Raumbuchungen').items.getById(fd.itemId).get().then(function(item){
console.clear();
console.log("Item: " + item);
var CreatedBy = item.AuthorId;
var userID = _spPageContextInfo.userId;
console.log("CreatedBy: " + CreatedBy);
console.log("UserID: " + userID);
/* Check, ob Verantwortlich ID = currentUser, dann darf er auch */
var value = fd.field('Verantwortlich').value.email;
console.log("VerantwortlichMail: " + value);
sp.web.siteUsers.getByEmail(value).get().then(function(result) {
var verantwortlichUserID = result.Id;
//console.log("verantwortlichUserID: " + verantwortlichUserID);
if (CreatedBy == userID || verantwortlichUserID == userID){
//User verifiziert pnp.sp.web.lists.getByTitle('Raumbuchungen').items.getById(fd.itemId).delete().then(function(){
window.location.href = "http://xxx/websites/raumbuchungen/SitePages/PlumsailForms/Raumbuchungen/Ereignis/NewForm.aspx";
});
}
else{
//User nicht verifiziert, abbrechen
alert("Nur der Ersteller kann die Raumbuchung verschieben.");
}
});
});
Does somebody know why it stopped working? I haven't changed anything.