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
*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'
)
)
)
Solved! Go to Solution.
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 */
)
}
)
)
)
)
Best regards,
Sik
If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.
@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'
)
}
);
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 */
)
}
)
)
)
)
Best regards,
Sik
If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.
@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'
)
}
);
User | Count |
---|---|
260 | |
123 | |
99 | |
48 | |
43 |