cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lowcodelewis
Frequent Visitor

Handling missing manager in AAD when using default property for people combobox

Hi, 

 

I have a form which includes 2 people fields. One is the person I am creating a report on, and the other is the line manager of that employee I am making the report on. The line manager should pull from AAD using the default property or combobox default selected items.

 

This works except for when a manager isn't populated in AAD. 

 

How do we handle missing values for managers in Azure AD for this kind of requirement? This is the error experienced:

lowcodelewis_0-1660338320282.png

 

This has occurred with trying this syntax in the default property of the data card on the form:

Office365Users.Manager(DataCardValue3.Selected.Email)

 

This has also occurred when using the following syntax:

},
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: Office365Users.ManagerV2(DataCardValue3.Selected.Email).department,
Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
DisplayName: Office365Users.ManagerV2(DataCardValue3.Selected.Email).displayName,
Email: Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
JobTitle: Office365Users.ManagerV2(DataCardValue3.Selected.Email).jobTitle,
Picture: ""
}

 

Thank you in advance!

2 ACCEPTED SOLUTIONS

Accepted Solutions
BCBuizer
Super User
Super User

Hi @lowcodelewis ,

 

You can use any of these functions to deal with this: https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

lowcodelewis
Frequent Visitor

Hi @BCBuizer

 

Just to let you know I have managed to correctly use the IfError() function now by putting it around each of the values after defining the column in the user record.

 

I.e. Claims: IfError("i:0#.f|membership|" & Office365Users.ManagerV2(DataCardValue11.Selected.Email).mail,Blank())

 

Thank you so much for your help!

View solution in original post

9 REPLIES 9
BCBuizer
Super User
Super User

Hi @lowcodelewis ,

 

You can use any of these functions to deal with this: https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
lowcodelewis
Frequent Visitor

It looks like we have a limitation here of the Office 365 Users connector. Its a long shot, but I'll leave this post open in case anyone has any ideas

lowcodelewis_0-1660338636842.png

 

@BCBuizer - Ah brilliant - I'll take a look, thank you!

 

I am now using this syntax:

 

IfError(

If(Form1.Mode = FormMode.New,

If(incorrectEmployeeInvolvedLineManager = true, Blank(),

If(DataCardValue2.Value = false,

{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: Office365Users.ManagerV2(User().Email).department,
Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).mail,
DisplayName: Office365Users.ManagerV2(User().Email).displayName,
Email: Office365Users.ManagerV2(User().Email).mail,
JobTitle: Office365Users.ManagerV2(User().Email).jobTitle,
Picture: ""
},
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: Office365Users.ManagerV2(DataCardValue3.Selected.Email).department,
Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
DisplayName: Office365Users.ManagerV2(DataCardValue3.Selected.Email).displayName,
Email: Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
JobTitle: Office365Users.ManagerV2(DataCardValue3.Selected.Email).jobTitle,
Picture: ""
})),

ThisItem.'Employee Involved Line Manager'), Blank())

 

and still seeing the error and not able to submit the form if the line manager is blank. For further background on this syntax, I am using a form for both new records and editing with form modes and item variables. I have a checkbox on the form for users to select, and set the line manager field blank if they believe it to be pulled incorrectly. Then if the toggle/datacardvalue2 is set to false I want to take the current users manager, and if it is not set to false i will take the combobox selected value to find the line manager, from the manually selected employee reporting on.

 

Any ideas on how to implement the iferror part here - can you see if I'm doing anything wrong?

BCBuizer
Super User
Super User

Hi @lowcodelewis ,

 

Only the parts that may cause error should be wrapped in an IfError function. I made a few other tweaks to your code as well since some of the conditions involved booleans which you don't have to evaluate: you can use their value directly:

 

If(
	Form1.Mode = FormMode.New,
	If(
		incorrectEmployeeInvolvedLineManager,
		Blank(),
		If(
			!DataCardValue2.Value,
			IfError(
				{
				'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
				Department: Office365Users.ManagerV2(User().Email).department,
				Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(User().Email).mail,
				DisplayName: Office365Users.ManagerV2(User().Email).displayName,
				Email: Office365Users.ManagerV2(User().Email).mail,
				JobTitle: Office365Users.ManagerV2(User().Email).jobTitle,
				Picture: ""
				},
				Blank()
			),
			IfError(
				{
				'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
				Department: Office365Users.ManagerV2(DataCardValue3.Selected.Email).department,
				Claims: "i:0#.f|membership|" & Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
				DisplayName: Office365Users.ManagerV2(DataCardValue3.Selected.Email).displayName,
				Email: Office365Users.ManagerV2(DataCardValue3.Selected.Email).mail,
				JobTitle: Office365Users.ManagerV2(DataCardValue3.Selected.Email).jobTitle,
				Picture: ""
				},
				Blank()
			)
		)
	),
	ThisItem.'Employee Involved Line Manager'
)


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
lowcodelewis
Frequent Visitor

Thank you for this @BCBuizer . I'm afraid the value returned in the combobox is still [[error]] and this error returned when trying to submit the form:

lowcodelewis_0-1660395682244.png

 

BCBuizer
Super User
Super User

Hi @lowcodelewis ,

 

I quickly checked the Office365User connector documentation and I don't see a ManagerV2() in there, only Manager():

 

https://docs.microsoft.com/en-us/power-apps/maker/canvas-apps/connections/connection-office365-users...

 

Can you try with Office365Users.Manager() instead:

 

If(
	Form1.Mode = FormMode.New,
	If(
		incorrectEmployeeInvolvedLineManager,
		Blank(),
		If(
			!DataCardValue2.Value,
			IfError(
				{
				'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
				Department: Office365Users.Manager(User().Email).department,
				Claims: "i:0#.f|membership|" & Office365Users.Manager(User().Email).mail,
				DisplayName: Office365Users.Manager(User().Email).displayName,
				Email: Office365Users.Manager(User().Email).mail,
				JobTitle: Office365Users.Manager(User().Email).jobTitle,
				Picture: ""
				},
				Blank()
			),
			IfError(
				{
				'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
				Department: Office365Users.Manager(DataCardValue3.Selected.Email).department,
				Claims: "i:0#.f|membership|" & Office365Users.Manager(DataCardValue3.Selected.Email).mail,
				DisplayName: Office365Users.Manager(DataCardValue3.Selected.Email).displayName,
				Email: Office365Users.Manager(DataCardValue3.Selected.Email).mail,
				JobTitle: Office365Users.Manager(DataCardValue3.Selected.Email).jobTitle,
				Picture: ""
				},
				Blank()
			)
		)
	),
	ThisItem.'Employee Involved Line Manager'
)

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
lowcodelewis
Frequent Visitor

Hi @BCBuizer ,

 

Thanks again.

 

Unfortunately I didn't have any luck here. I noticed when looking at the previews of the records for the one with a missing line manager, the error was on each field and obviously therefore not the Odata type or picture as these are hard coded. I thought I might try to put the IfError() around each field of the records, but that doesn't work in this case of course with the way it is a record.

lowcodelewis
Frequent Visitor

Hi @BCBuizer

 

Just to let you know I have managed to correctly use the IfError() function now by putting it around each of the values after defining the column in the user record.

 

I.e. Claims: IfError("i:0#.f|membership|" & Office365Users.ManagerV2(DataCardValue11.Selected.Email).mail,Blank())

 

Thank you so much for your help!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,389)