cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marcosa-ca
New Member

Office365Users.Manager throws error when CEO has no manager

We pointed a sample/demo Org Chart app at our AzureAD, and the first thing that happened was they put in the CEO's name, and it gave an error: 

 

The service returned an error: Office365Users!Manager: {"status":404,"message":"No manager found for the specified user.","source":"127.0.0.1"}

 

This is because the CEO has no manager, of course.   

 

I tried an if statement to see if a value was returned...

 

The conditional works fine (it returns True when there is no manager, False when there is not)

IsBlank(Office365Users.Manager(First(Manager).Id))

 

But still throws the error.  In other words, simply testing to see if there is a Manager throws the error.  It seems kind of strange that it's not possible for there to be a null value in a field without an error being generated.  Especially when the demo/template app has stuff like "Visible; CountRows(Manager) > 0" which seems to indicate the form is designed to be able to handle people without a Manager. 

 

Anyone have any ideas on how to fix this systemically (as opposed to writing IF logic based on something like a specific job title, which works, but won't adapt to job title changes, etc.)?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @marcosa-ca,

 

Thanks for the feedback.

This seems to be the limitation of the Office365Users Connection (or saying the service).

If there is no Manager for the corresponding user ID, then the Office365Users.Manager() function would throw the error.

For the Job Title, please consider change the formula with the following:

If(First(Manager).JobTitle<>"CEO", 

   Office365Users.Manager(First(Manager).Id).DisplayName,

   "This is CEO")

For JobTitle Changes, we may create a single record table , then use filter function to check,

You can also define a single-column table with square brackets. An equivalent way to write the above:

[ "Strawberry", "Vanilla" ]

for example:

If(
   IsEmpty(
             Filter(["IT","Work", "CEO"],
                     Office365Users.MyProfile().JobTitle in ["IT","Work", "CEO"])
                      ),
  
  Office365Users.MyProfile().DisplayName,
  Office365Users.MyProfile().JobTitle)

The formula above would check if the JobTitle is within the value specified in the single column table ["IT","Work","CEO"], if the table returned by the filter is empty, which means the JobTitle doesn't match the value specified, then it will show the the User display Name, otherwise, it will show the JobTitle.

Adding some reference:

Understand tables and records in PowerApps

Hope the information above is helpful.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-micsh-msft
Community Support
Community Support

Hi @marcosa-ca,

 

Thanks for the feedback.

This seems to be the limitation of the Office365Users Connection (or saying the service).

If there is no Manager for the corresponding user ID, then the Office365Users.Manager() function would throw the error.

For the Job Title, please consider change the formula with the following:

If(First(Manager).JobTitle<>"CEO", 

   Office365Users.Manager(First(Manager).Id).DisplayName,

   "This is CEO")

For JobTitle Changes, we may create a single record table , then use filter function to check,

You can also define a single-column table with square brackets. An equivalent way to write the above:

[ "Strawberry", "Vanilla" ]

for example:

If(
   IsEmpty(
             Filter(["IT","Work", "CEO"],
                     Office365Users.MyProfile().JobTitle in ["IT","Work", "CEO"])
                      ),
  
  Office365Users.MyProfile().DisplayName,
  Office365Users.MyProfile().JobTitle)

The formula above would check if the JobTitle is within the value specified in the single column table ["IT","Work","CEO"], if the table returned by the filter is empty, which means the JobTitle doesn't match the value specified, then it will show the the User display Name, otherwise, it will show the JobTitle.

Adding some reference:

Understand tables and records in PowerApps

Hope the information above is helpful.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Apologies for the delay.  Coded around this by using 'exactin' with || (or) rather than <> because there are multiple cases and titles with slight variances that have no supervisor.  This worked, but it needs to be staticaly defined (we have to specify the strings to partial match against - if a new job title happens, everything will break), and needs to be done in multiple places - so this is not an ideal solution.  However, thank you for confirming that there is no way around this errror message to do it correctly based on the inability of the Office365Users method failing to silently deal with a field being empty - this saved me a lot of second-guessing whether I was using a band-aid if there was a real solution available (but apparently there is not).  Thanks so much!!

Anonymous
Not applicable

I posted a solution not depending on title over here.

Don't panic !

Simple Enable this:
Go to
«Experimental features» section -> Enable «Formula-level error management»

and Use this Formula: IfError(Office365Users.ManagerV2(User().Email).displayName,"");

Was glad to help 😊

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,802)