cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Lookup on a Collection

Hello Community!

I'm having some issues with Lookup function in collections. My problem is the following:

  • I have a canvas app that uses the D365CE connector (not CDS connector)
  • I'm retrieving opportunities in a Gallery
  • I want to display the opportunity owner in a field on the gallery

Unfortunately, the Owner field in the Opportunity table only contains the GUID, not the name of the Owner.


I have added a second data source for Users in the app, and a function to Lookup the user like this

LookUp(Users, User= ThisItem.Owner).fullname


With this, I can see the owner of the opportunity in each gallery item.

 

 

However, this seems do a lookup per gallery row, and it seems not the best way (a query per gallery row seems not a very nice solution performance wise)

 

I have tried to use a collection to store all the users when the app loads, and I want to do the LookUp against the collection instead of against the data source. Lookup would be done locally, meaning less queries to the Users table in CRM.

 

So, in the load of the app, I do this

 

ClearCollect(CachedUserList, ShowColumns(Users,"systemuserid","internalemailaddress","fullname"))

 

 

In addition, I change the LookUp function to do

LookUp(CachedUserList, systemuserid= ThisItem.Owner).fullname 

instead of

LookUp(Users, User= ThisItem.Owner).fullname //LookUp against table

When I do this change and run the app, the lookup function does not return any value on any of the rows of the gallery. If I check at the collection I see that the table has been dumped into the collection, so there is data in the collection. I don't know what I am doing wrong.

Can you please advise?

 

1 REPLY 1
Highlighted
Dual Super User
Dual Super User

Re: Lookup on a Collection

Hi @gluengo 

 

Can you try to update your expression as:
 
Gallery -> Items -> AddColumns(Opportunities, "OwnerName",LookUp(CachedUserList, systemuserid= Owner).fullname)
 
Through this, you can get the name of Owner by using ThisItem.OwnerName
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

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