Hi, I'm trying to auto display the column details based on your previous script. I'm not sure what should I add in to make it change accordingly once Superior name displayed. The Designation2 column is blank during 1st prefill (based on EmployeeName column), when I manually select Superior column, then only Designation2 is display. Please help me how to auto update this.
Below is the script:
fd.spRendered(function() {
//executes the below steps on field change
fd.field('EmployeeName').$on('change', function(value) {
//gets properties of the selected user
fd.field('Appraisee').value = fd.field('EmployeeName').value.EntityData.AccountName;
fd.field('ol_Department').value = fd.field('EmployeeName').value.EntityData.Department;
fd.field('Appraisee').value = fd.field('EmployeeName').value.EntityData.Email;
//fd.field('UserObjType').value = fd.field('EmployeeName').value.EntityData.PrincipalType;
//fd.field('UserEmail2').value = fd.field('EmployeeName').value.EntityData.SIPAddress;
//fd.field('UserID').value = fd.field('EmployeeName').value.EntityData.SPUserID;
fd.field('Designation').value = fd.field('EmployeeName').value.EntityData.Title;
//gets manager name of the selected user
pnp.sp.profiles.getPropertiesFor(fd.field("EmployeeName").value.Key).then(function(result) {
var props = result.UserProfileProperties;
for(var i = 0; i < props.length; i++){
if(props[i].Key == "Manager"){
fd.field("Superior").value = props[i].Value;
fd.field("Appraiser").value = props[i].Value;
//fd.field("HOD").value = props[i].Value;
break;
}
}
});
});
//executes the below steps on field change
fd.field('Superior').$on('change', function(value) {
//gets properties of the selected user
//fd.field('Appraisee').value = fd.field('Superior').value.EntityData.AccountName;
//fd.field('ol_Department').value = fd.field('Superior').value.EntityData.Department;
//fd.field('Appraisee').value = fd.field('Superior').value.EntityData.Email;
//fd.field('UserObjType').value = fd.field('Superior').value.EntityData.PrincipalType;
//fd.field('UserEmail2').value = fd.field('Superior').value.EntityData.SIPAddress;
//fd.field('UserID').value = fd.field('Superior').value.EntityData.SPUserID;
fd.field('Designation2').value = fd.field('Superior').value.EntityData.Title;
//gets manager name of the selected user
pnp.sp.profiles.getPropertiesFor(fd.field("Superior").value.Key).then(function(result) {
var props = result.UserProfileProperties;
for(var i = 0; i < props.length; i++){
if(props[i].Key == "Manager"){
fd.field("HOD").value = props[i].Value;
break;
}
}
});
});
});