cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

LookUp function CDS same name fields (different entities)

Dear all,

 

I've been working on a product configurator app for my company based on data that we use in our Dynamics 365 CRM environment. I've come a long way using connections to Dynamics Data sources. Today I tried to experiment a bit with making connections to the same entities via CDS.

 

Currently I'm facing an issue that I don't have problems with when using Dynamics data sources, however I would like to understand how to do it with CDS connections.

 

I have an entity Products with the field Product (containing the GUID of the record) and I have an entity Projectitem with a LookUp field named Product (in which I can select a Product record). I'm creating a collection in the app in which I'm searching for the product name in the Products entity based on a selection of Projectitem records. For the name I'm using a LookUp:

 

ForAll(
          Projectitems;
          Collect(
                Selected_Product_Table;
                {
                         Productname: LookUp(
                         Products;
                         Product = Product; Name
                         )
                }
           )
)

I've tried to specify both Product fields by referring to the entity in the formula, meaning: Products[@Product] = Projectitems[@Product]. I also tried using the unique environment names, but no luck. Basically I've tried all combinations of reference, display names and environment names... no luck.

 

In the app that I've based on the Dynamics data sources, this LookUp works with specifying the unique environment names.

 

Can anybody point out what I'm doing wrong and how to build up the correct reference to get the name of the product selected with a LookUp field on a different entity?

 

Appreciating any feedback!

 

Best regards,

 

M.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate I
Advocate I

Re: LookUp function CDS same name fields (different entities)

Dear @yashag2255 ,

 

Thank you for your reply!

 

Unfortunately this isn't the solution, however it did help me find the right one - thinking about your comment on not having to use the LookUp function.

 

For filling the variable 'Productname' in a new collection I now do the following:

 

ForAll(
        Projectitems;
                      Collect(
                              Selected_Products_Table;
                              {
                              Productname: Product.Name
                              }
                       )
)

Because I'm doing this for the Projectitems entity (in the ForAll Function) when I refer to Product (in the Product.Name part) it's referring to the Product LookUp field on the Projectitem record. Then by adding the .Name it's using the name field of the Product record.

 

Again thanks for giving me the insight!

 

Best regards,

 

M.

View solution in original post

3 REPLIES 3
Highlighted
Dual Super User
Dual Super User

Re: LookUp function CDS same name fields (different entities)

Hi @MWierckx 

 

To collect the names of all the Products from the lookup field, you do not need to perform a LookUp operation, this can directly be fetched from the entity. In dynamics the attribute that contains the record differs a bit. Can you try out the below expression:
 
ClearCollect(Selected_Product_Table, Projectitems.'Product (cbisa_Product)'.Name)
 
You need to replace the highlighted part with the actual attribute name, this need to be similar to 'LookUpFieldName (prefix_LookUpFieldName)', one with the logical name.

 

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!

Highlighted
Advocate I
Advocate I

Re: LookUp function CDS same name fields (different entities)

Dear @yashag2255 ,

 

Thank you for your reply!

 

Unfortunately this isn't the solution, however it did help me find the right one - thinking about your comment on not having to use the LookUp function.

 

For filling the variable 'Productname' in a new collection I now do the following:

 

ForAll(
        Projectitems;
                      Collect(
                              Selected_Products_Table;
                              {
                              Productname: Product.Name
                              }
                       )
)

Because I'm doing this for the Projectitems entity (in the ForAll Function) when I refer to Product (in the Product.Name part) it's referring to the Product LookUp field on the Projectitem record. Then by adding the .Name it's using the name field of the Product record.

 

Again thanks for giving me the insight!

 

Best regards,

 

M.

View solution in original post

Highlighted
Community Support
Community Support

Re: LookUp function CDS same name fields (different entities)

Hi @yashag2255 @MWierckx 

 

Thanks for your posts and @MWierckx  thanks for your solution.

This will be useful for others.

 

Best Regards.

Yumia

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

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

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!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (8,291)