I have referred to the article "Use Graph API to access user profile properties," but encountered an issue where the Manager property is not retrieved. Upon further investigation, I realized that a separate request is required to obtain the manager's name using the Graph API. Can someone assist me with the syntax for this separate request?
This is my request :
Hello @madhawa.rajapaksha,
There is a separate request for getting the manager in Graph APi: List manager - Microsoft Graph v1.0 | Microsoft Learn
I would suggest using PnPjs instead to retrieve the manager property:
function updateUserInfo() {
var employee = fd.field('User').value;
if (employee && employee.Key){
pnp.sp.profiles.getPropertiesFor(employee.Key).then(function(result) {
var props = result.UserProfileProperties;
for (var i = 0; i < props.length; i++) {
switch (props[i].Key) {
case 'Manager':
fd.field('Manager').value = props[i].Value;
break;
case 'Department':
fd.field('Department').value = props[i].Value;
break;
case 'Title':
fd.field('JobTitle').value = props[i].Value;
break;
case 'CellPhone':
fd.field('Mobile').value = props[i].Value;
}
}
});
}
}
fd.spRendered(function() {
//executes updateUserInfo on field change
fd.field('PersonFieldName').$on('change', updateUserInfo);
});