cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sifu
Post Prodigy
Post Prodigy

IF something Get direct reports.... returns also an error (invalid value for parameter ID)

Hello all,

I am using this formula:

If(roleCart.Text = "Manager" And ForWho.Selected.Value = "For a member of my team",
First(Filter(Office365Users.DirectReportsV2( Office365Users.MyProfileV2().userPrincipalName ).value, displayName = UserName.Text)).userPrincipalName)

where rolecart is a label and forwho is a dropdown.... but its not working completely... it gives me following error (invalid value for parameter ID), but it still returns the UPN...

Sifu_0-1611775613714.png

I noticed that if i exclude the "And ForWho.Selected.Value = "For a member of my team" ", it will work without any error:

If(roleCart.Text = "Manager",
First(Filter(Office365Users.DirectReportsV2( Office365Users.MyProfileV2().userPrincipalName ).value, displayName = UserName.Text)).userPrincipalName)

 

Has anyone any idea what sorcery this is?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Sifu 

Give this a shot:

If(roleCart.Text = "Manager" && ForWho.Selected.Value = "For a member of my team",
    With({_user:User().Email)},
        LookUp(Office365Users.DirectReportsV2(_user).value, 
            displayName = UserName.Text, 
            userPrincipalName
        )
    )
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@Sifu 

Please consider changing your Formula to the following:

If(roleCart.Text = "Manager" && ForWho.Selected.Value = "For a member of my team",
    LookUp(Office365Users.DirectReportsV2(Office365Users.MyProfileV2().userPrincipalName ).value, 
        displayName = UserName.Text, 
        userPrincipalName
    )
)

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

unfortunately still the same

"Office365Users.DirectReportsV2 failed: The method 'DirectReportsV2' has an invalid value for parameter 'id'"

RandyHayes
Super User
Super User

@Sifu 

Give this a shot:

If(roleCart.Text = "Manager" && ForWho.Selected.Value = "For a member of my team",
    With({_user:User().Email)},
        LookUp(Office365Users.DirectReportsV2(_user).value, 
            displayName = UserName.Text, 
            userPrincipalName
        )
    )
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

well well well, someone was really good here, this one worked... can you explain why ? just so i dont ask the same question in different scenario again...

Also I think the issue why this would not run could be related to the fact that the "ForWho" is on a different screen...

When i placed the label with the same formula in the same screen it was working, but i could not work out how to transport the value to the different screen, even variable was not working although if i let a label display the variable it worked... just not in my formula (not even if i let my formula read the label)

RandyHayes
Super User
Super User

@Sifu 

No, controls are global in the app.  You can access their values from any screen in the app - skip the variables, they are duplicate and unnecessary .

 

In this formula I provided, we did two things:

1) We skipped using the Office365Users.MyProfileV2() and went with the User email address, which is really all you need.

2) We took the above email and put that in a Scoped With variable.  Sometimes putting the function directly into another function like that will cause bad results.  I see it only on a couple of different connector actions.  This one seems temperamental. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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
Top Kudoed Authors
Users online (4,459)