cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SandraAkujobi
Post Partisan
Post Partisan

Displaying Department related to user

I am trying to display departments that related to the current user. Originally in my SharePoint list I have a column called department which is a choice field   options to choose from (Office, Site, Works). On power apps I've added in that field to my form Now on Active Directory we have added a department column on there (we didn't have it before which led to the creation of department column being a choice field on SharePoint) and I'm trying to display the department relevant to the current user on the app but I'm quite unsure on how to do so.

 

Also I would like to create a department collection that will display the names of staff within that department, how would I go about it?

1 ACCEPTED SOLUTION

Accepted Solutions

@SandraAkujobi 

You have a variety of "sins" going on here...

 

First, you should leave your Default property of the datacard to be what it originally was.  ThisItem.Department  You should do this so that you can have the column value as is stored in the list available to you in the datacard.

 

Next, your Department column you mentioned is a Choice column.  So, you will need to account for that.

 

Next, what are you planning to use for your DataCardValue4 Items property?  Are you still going with Choices for your original choice column?  Or, now that you are going to capture the real department defined in their profile, will you be gathering a list of departments from Office365/Active Directory?

 

Next, depending on the choices (no pun intended) above, you will then need to compensate for the fact that you have a Choice column and you will need to set the value of it (and it will need to be what is already defined in the choice column definition - unless you allow write in values).

 

Quite honestly, now that you have access to the defined department in the user profile, I would suggest getting rid of the Choice column in your list and replacing it with a Text column.  Then simply store the value from the User profile department.

OR, better still is to set a Person column in your list with the proper Employee...then you can simply refer to that column to get the department, as it will already be in that Person record stored.

 

 

 

_____________________________________________________________________________________
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

@SandraAkujobi 

You can get the user department directly from the Office 365 Users connector.

 

Office365Users.MyProfileV2().department

 

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!

@RandyHayes I'd previously put that formula in the datacard default function and it still displayed an error but the funny thing is that below the function box you can see that it actually shows what department that user is in but it does not display on the form.

Screenshot (111).png

 

@SandraAkujobi 

You have a variety of "sins" going on here...

 

First, you should leave your Default property of the datacard to be what it originally was.  ThisItem.Department  You should do this so that you can have the column value as is stored in the list available to you in the datacard.

 

Next, your Department column you mentioned is a Choice column.  So, you will need to account for that.

 

Next, what are you planning to use for your DataCardValue4 Items property?  Are you still going with Choices for your original choice column?  Or, now that you are going to capture the real department defined in their profile, will you be gathering a list of departments from Office365/Active Directory?

 

Next, depending on the choices (no pun intended) above, you will then need to compensate for the fact that you have a Choice column and you will need to set the value of it (and it will need to be what is already defined in the choice column definition - unless you allow write in values).

 

Quite honestly, now that you have access to the defined department in the user profile, I would suggest getting rid of the Choice column in your list and replacing it with a Text column.  Then simply store the value from the User profile department.

OR, better still is to set a Person column in your list with the proper Employee...then you can simply refer to that column to get the department, as it will already be in that Person record stored.

 

 

 

_____________________________________________________________________________________
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!

@RandyHayes that worked well. Also that last statement you mentioned, how would I be able to do that. 

@SandraAkujobi 

If you have a person column and a person in it, you can reference the personColumnName.Department property of the record.  It will have the department in it automatically (as defined in their profile).

_____________________________________________________________________________________
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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,583)