cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Responsive Resident
Responsive Resident

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
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

5 REPLIES 5
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Responsive Resident
Responsive Resident

unfortunately still the same

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

Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Responsive Resident
Responsive Resident

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)

Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (92,413)