web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Collect lookup ...
Power Apps
Answered

How to Collect lookup GUID value from CDS lookup Field or Join two CDS Data Sources

(0) ShareShare
ReportReport
Posted on by 2,996

How to join two CDS data source via lookup GUID value to get the GUID value of the lookup value of parent record? (in short, grandparent record GUID)


E.g. I have 3 entities.
1. Assessment Section
2. Assessment Question
3. Assessment Details

Assessment Details has a lookup field for entity Assessment Question.
Assessment Question has a lookup field for entity Assessment Section.

What I want is the GUID value for "Assessment Section" lookup field on "Assessment Question" entity to be added to the collection together with "Assessment Details" data

 

I tried to AddColumn using the following formula but

  • zzlocalassessmentsectionid (getting a lookup value of lookup record returns an empty data even though "zzTextField" returns the data though since it is a text field)
  • zzlookupassessmentsectionid (lookup to the Assessment Question returns value for the other text fields but not the lookup field. If I set the same Lookup function to a label text value with hardcoded "Assessment Question" GUID, it is working fine)

*Screenshot attached*

 

 

ClearCollect(colTest,
 AddColumns
 (
 'Assessment Details',
 "zzTextField",
 assessmentquestionid.'Question Text',
 "zzlocalassessmentsectionid",
 assessmentquestionid.'Assessment Section',
 "zzlookupassessmentsectionid",
 LookUp
 (
 'Assessment Questions', 
 'Assessment Question' = assessmentquestionid.'Assessment Question', 
 'Assessment Section'.'Assessment Section'
 )
 )
)

 

 

Annotation 2019-11-12 012000.png
Categories:
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi  @LinnZawWin ,

     

    What is the assessmentquestionid? the lookup field of 'Assessment Details'?

    I'm sure this is not a easy way, but it works on my test. We can't get the Lookup value of lookup field in batches, so we have to first get the GUID field Name of Assessment Question, then patch the GUID2(the Assessment Section lookupfield of  Assessment Questions ) to collection. Please try the following formula, If this doesn't work, please post back more details information.

    Note: I assume that GUID field Name of three entity is the same with entity name.

     

    ClearCollect(colTest,
     AddColumns
     (
     'Assessment Details',
     "zzTextField",
     assessmentquestionid.'Question Text',
     "GUID1"
     assessmentquestionid.'Assessment Question', /*Get GUID field Name of Assessment Question lookup field*/
     "GUID2",
     ""
     )
    );
    ClearCollect(coltest3,colTest);
    ClearCollect(coltest4,'Assessment Question');
    ForAll(
     coltest4,
     ForAll(
     coltest3,
     If(
     'Assessment Question' = GUID1,
     Patch(
     colTest,
     LookUp(
     colTest,
     'Assessment Details' = coltest3[@'Assessment Details']
     ),
     {
     GUID2: LookUp(
     'Assessment Question',
     'Assessment Question' = coltest4[@'Assessment Question'],
     'Assessment Section'.'Assessment Section' /* LookUpfied.GUID */
     )
     }
     )
     )
     )
    )

     

    Snipaste_2019-11-12_14-31-40.png

    Best regards,

    Sik

    If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.

  • Verified answer
    Linn Zaw Win Profile Picture
    2,996 on at

    @v-siky-msft Thanks for your response. It's a shame that we can't get the Lookup value of the lookup field (not even GUID).

    Your sample code is also useful for me. It inspired me to come up with the idea to patch the collection instead.

    And here is the modified version to update all the rows of the collection and populate the Lookup GUID value of the parent record.

    UpdateIf(
     colTest, 
     true, 
     {
     assessmentsectionid: LookUp
     (
     'Assessment Questions', 
     'Assessment Question' = dxc_assessmentquestionid,
     'Assessment Section'.'Assessment Section'
     )
     }
    );

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard