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 III
Dual Super User III

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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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