cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Community Support
Community Support

Re: Office365Users.Manager throws error when CEO has no manager

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

3 REPLIES 3
Community Support
Community Support

Re: Office365Users.Manager throws error when CEO has no manager

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

marcosa-ca
New Member

Re: Office365Users.Manager throws error when CEO has no manager

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!!

mackaaij
Frequent Visitor

Re: Office365Users.Manager throws error when CEO has no manager

I posted a solution not depending on title over here.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (5,383)