web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Canvas App DirectRepor...
Power Apps
Answered

Canvas App DirectReportsV2 - The method 'DirectReports' has an invalid value for parameter 'userId'

(0) ShareShare
ReportReport
Posted on by 96

I have an org chart that is using a gallery to show direct reports with this formula in the Items property:

 

If(
IsBlank(varSelectedUser),
Filter(
Office365Users.DirectReportsV2(varLoggedInUser).value,accountEnabled=true),
Filter(
Office365Users.DirectReportsV2(varSelectedUser).value,accountEnabled=true)
)

 

but it's showing an error of The method 'DirectReports' has an invalid value for parameter 'userId' at the top of the screen when the app first loads (I added the if statements as a potential fix but did not work).

RIYxWRK_0-1673000937102.png

 

Before I put in the If statements in the code above I was using simply: 

 

Office365Users.DirectReportsV2(varSelectedUser).value

 

on the gallery Items property.

 

The build studio shows no errors and the Org Browser app works fine after the initial error on load. From what I have read this is a common occurrence whenever the connector encounters ANY error 🙄

 

How can I suppress this error on first load. Are there any error suppressions functions?

 

Appreciate any advice and thanks in advance 😁

 

Categories:
I have the same question (0)
  • Anchov Profile Picture
    1,986 on at

    Can you show the code where you are setting your variables varSelectedUser and varLoggedInUser?

  • Anchov Profile Picture
    1,986 on at

    My initial thoughts are you are going to want to make your API call in the Onvisble property of your screen and load the results into a collection.

     

     

    Set(varLoggedInUser, User().Email);
    ClearCollect(colDirectReports),Office365Users.DirectReportsV2(varLoggedInUser).value,accountEnabled=true);

     

     

     

     

     

    Then, you redefined the collection when varSelectedUser user is selected and set your gallery to  Items property to colDirectReports.

     

    What's happening is that PowerApps is trying to make the API call and display your gallery before any variables have been defined (because it is naturally a declarative programing language), so you need to "slow it down" and make it behave like a imperative language.

     

    Alternatively, you can try this (so it doesn't depend on the LoggedInUser variable to be defined first). 

     

     

    If(
    IsBlank(varSelectedUser),
    Filter(
    Office365Users.DirectReportsV2(User().Email).value,accountEnabled=true),
    Filter(
    Office365Users.DirectReportsV2(varSelectedUser).value,accountEnabled=true)
    )

     

     

     


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt  

  • Harry_rx Profile Picture
    96 on at

    Thanks for your suggestion-you confirmed what I thought may be happening. I tried 

    If(
    IsBlank(varSelectedUser),
    Filter(
    Office365Users.DirectReportsV2(User().Email).value,accountEnabled=true),
    Filter(
    Office365Users.DirectReportsV2(varSelectedUser).value,accountEnabled=true)
    )

    but it's still looking for that variable (can't check if it's blank because it doesn't exist yet-sigh). 

     

  • Harry_rx Profile Picture
    96 on at

    Is there a way to check in an IF statement if a variable exists?

  • Verified answer
    Harry_rx Profile Picture
    96 on at

    I managed to work around this issue. I created another screen called 'Initialisation' with a auto-start timer for 1 second. On timer end it auto navigates to the actual functional screen. This appears to give the variables time to get created or masks the error since that screen isn't in view yet. Either way that worked. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard