cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jade7669
Level: Powered On

filter a gallery by current CRM user

I have built an app with a gallery, but the currently returned list display all CRM Contact records regardless who is logged in.  Since User() doesn't return the systemuserid, I am not sure how I can achieve the goal and only return a list of contacts that are owned by the logged in user.  Please help!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: filter a gallery by current CRM user

@jade7669

 

You will need to connect to the Users table in CRM and first find the systemuserid of the logged in user -

 

LookUp(Users,fullname= User().FullName,systemuserid)

 

You can use this to Filter the gallery then.

 

hope it makes sense!

 

@Jeff_Thorpe

Office365 connector returns an id which is different from the one on CRM for the same user. I am assuming that Dynamics CRM acts as separate system/entity with it's own defined ids.


Vivek Bavishi aka That API Guy
PowerApps and Flow MVP
Blog | Twitter | YouTube | Community Profile | GitHub



If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
jade7669
Level: Powered On

Re: filter a gallery by current CRM user

Hi vivekb,

 

Thank you for your reply!!  I was just going to post a similar method as what you have suggested:

 

You were right, unfortunately the ownerid value in CRM is different from Office365 connector user id, and therefore I couldn't use that to retrieve data correctly. 

I had to store the current user (limited) info first as a context variable as the screen's OnVisible value:

MKC_PowerApp_ownerid_lookup_solution_1.png

Create a hidden text field to then lookup the current logged CRM user id:

MKC_PowerApp_ownerid_lookup_solution_2.png

And Finally set the gallery > Items to filter by active status and owned by user:

MKC_PowerApp_ownerid_lookup_solution_3.png

I had tried to combine these 3 steps into 1 previously and guess it was too complicated to process?!  The other downside of this is that the list does take a long time (30 secs depends on the record quantity) to return filtered data, but otherwise this has resolved this issue.

 

Thank you again!

View solution in original post

3 REPLIES 3
Super User
Super User

Re: filter a gallery by current CRM user

If the system user ID is part of the user's profile you could use the Office365Users connector to get that information.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Super User
Super User

Re: filter a gallery by current CRM user

@jade7669

 

You will need to connect to the Users table in CRM and first find the systemuserid of the logged in user -

 

LookUp(Users,fullname= User().FullName,systemuserid)

 

You can use this to Filter the gallery then.

 

hope it makes sense!

 

@Jeff_Thorpe

Office365 connector returns an id which is different from the one on CRM for the same user. I am assuming that Dynamics CRM acts as separate system/entity with it's own defined ids.


Vivek Bavishi aka That API Guy
PowerApps and Flow MVP
Blog | Twitter | YouTube | Community Profile | GitHub



If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
jade7669
Level: Powered On

Re: filter a gallery by current CRM user

Hi vivekb,

 

Thank you for your reply!!  I was just going to post a similar method as what you have suggested:

 

You were right, unfortunately the ownerid value in CRM is different from Office365 connector user id, and therefore I couldn't use that to retrieve data correctly. 

I had to store the current user (limited) info first as a context variable as the screen's OnVisible value:

MKC_PowerApp_ownerid_lookup_solution_1.png

Create a hidden text field to then lookup the current logged CRM user id:

MKC_PowerApp_ownerid_lookup_solution_2.png

And Finally set the gallery > Items to filter by active status and owned by user:

MKC_PowerApp_ownerid_lookup_solution_3.png

I had tried to combine these 3 steps into 1 previously and guess it was too complicated to process?!  The other downside of this is that the list does take a long time (30 secs depends on the record quantity) to return filtered data, but otherwise this has resolved this issue.

 

Thank you again!

View solution in original post

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,326)