cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gluengo
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
yashag2255
Dual Super User II
Dual Super User II

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (70,854)