Hi @nmn_lamba ,
That is why i mentioned " It may be tricky", since ForAll always take some time to complete, especially in production environments with a large number of users. The only way I can think of is to periodically save the results of collections such as VarAll to a data source like an SP list, and then dropdown can refer directly to that SP list.
For your second question, for a level 3 manager, you can try to add a condition to judge the selected user's level then create another collection called "VarLevel3All ", like:
If(Office365Users.UserProfile(User().Email).JobTitle="Level3",
ClearCollect(var1,...);
ClearCollect(var2,...);
Var(VarLevel3All,var1,var2)
)
Then the dropdown should be:
If(Office365Users.UserProfile(User().Email).JobTitle="Level3",
VarLevel3All.UserPrincipalName,
varAll.UserPrincipalName
)
To get the count of selected user's reports(level 2 or level1), you need create a new collection, formula like this:
ClearCollect(
var1,
Filter(
Office365Users.DirectReports(Dropdown1.Selected.UserPrincipalName),
AccountEnabled = true
).UserPrincipalName
);
Clear(var2);
ForAll(
var1,
Collect(
var2,
Office365Users.DirectReports(UserPrincipalName)
)
);
ClearCollect(varSelectedAll,var1,var2)
At last, add a label beside dropdown, set its Text to:
CountRows(varSelectedAll)
You can also set its Visible to:
If(Office365Users.UserProfile(Dropdown1.Selected.UserPrincipalName).JobTitle="Level2"||Office365Users.UserProfile(Dropdown1.Selected.UserPrincipalName).JobTitle="Level1",true,false)
Best regards,
Allen