cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

How do I run validation on a chosen Manager (people picker from SharePoint)

In the SPO form. I've created some validation rules via InfoPath 2013 Designer.

 

I have this validation that:

 

If Department = Technical Support and

Manager isnotequalto John Smith and

Manager isnotequalto Adam Jones

 

Screentip: Please choose the right Manager for your department

 

Can I achieve the same in PowerApps? I need to have option to add multiple departments. Intention is to not let the users choose wrong Manager for their leave forms. It works fine in the SPO but not within the mobile app.

 

Thanks

 

Ifti

4 REPLIES 4
Advocate III
Advocate III

You can use the Office 365 Users Connector to get this information. It provides the following APIs which you would then be able to use in your validation function. Note for your particular case, you will probably need to create an additional configuration list which will store the department and the associated manager. Then query that list to get the departments and managers and you can those in combination with the below functions. Let me know if you need more help creating that validation logic.

 

Current User

Office365Users.MyProfile().Department

Office365Users.MyProfile().DisplayName

Office365Users.MyProfile().GivenName

Office365Users.MyProfile().Id

Office365Users.MyProfile().JobTitle

Office365Users.MyProfile().Mail

Office365Users.MyProfile().MailNickname

Office365Users.MyProfile().Surname

Office365Users.MyProfile().TelephoneNumber

Office365Users.MyProfile().UserPrincipalName

Office365Users.MyProfile().AccountEnabled

 

To show information about another user:
Office365Users.UserProfile(name@company.com).Department

Office365Users.UserProfile(name@company.com).DisplayName
Office365Users.UserProfile(name@company.com).GivenName
Office365Users.UserProfile(name@company.com).Id
Office365Users.UserProfile(name@company.com).JobTitle
Office365Users.UserProfile(name@company.com).Mail
Office365Users.UserProfile(name@company.com).MailNickname
Office365Users.UserProfile(name@company.com).Surname
Office365Users.UserProfile(name@company.com).TelephoneNumber
Office365Users.UserProfile(name@company.com).UserPrincipalName
Office365Users.UserProfile(name@company.com).AccountEnabled

 

To show information about another user's manager:
Office365Users.Manager(name@company.com).Department
Office365Users.Manager(name@company.com).DisplayName
Office365Users.Manager(name@company.com).GivenName
Office365Users.Manager(name@company.com).Id
Office365Users.Manager(name@company.com).JobTitle
Office365Users.Manager(name@company.com).Mail
Office365Users.Manager(name@company.com).MailNickname
Office365Users.Manager(name@company.com).Surname
Office365Users.Manager(name@company.com).TelephoneNumber
Office365Users.Manager(name@company.com).UserPrincipalName
Office365Users.Manager(name@company.com).AccountEnabled

Community Support
Community Support

Hi @ifti,

 

Yes, you can.

As @stormea suggested, you could work with the Offie365users connection under PowerApps:

Office 365 Users connection in PowerApps

For current user information, we could take use of User() function:

User function in PowerApps

To show the Manager of current user in a dropdown control, we could take use of the formula below in the items property of the dropdown:

table(

   Office365Users.Manager(

        User().Email

                        )

         )

48.PNG

Post back if you have any further questions regarding this issue.

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.

Hi mate,

 

Thanks for your response.

 

Due to the requirements, I have to use specific people to choose from depending on the chosen department.

 

I've added some codes in the "Validate" section of both Manager card and on a "submit" button. They don't do anything no matter which person I choose.

 

What I need is a proper code for validation that works like this:

 

If Department = Tech Support, Manager has to be either A or B or C, 

If Department = Sales, Manager has to be either D or E or F

....

....

 

If the chosen person isn't from them, then either:

1) Make that box red and show a notification at the top saying this field isn't valid (optional: let me define the error message)

2) Otherwise when the user submits the form, stop letting the user and give an error (like above)

 

Hope I'm clear with my requirements and the expected result.

 

Cheers,

Ifti

Advocate II
Advocate II

Any update guys?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,475)