I have a hierarchical Questions entity where each record (i.e. Question) has a parent via a M-1 hierarchical relationship and is associated to other records via a M-M non-hierarchical relationship. Within my application, I'm trying to collect all associated records of a given record AND the parents of those associated records. Collecting the parents is the problem.
My current approach looks like this:
//Step 1: Define context variable from Question gallery selection
UpdateContext(
{
locCurrentQuestionRecord:Lookup(Questions,Question=Gallery.Selected.Question)
}
);
//Step 2: Collect Associated Records via the M-M relationship (this works fine)
ClearCollect(
colAssociatedQuestions,
locCurrentQuestionRecord.'Questions (xxxx_AssociatedQuestions)'
);
//Step 3: Collect Parents of Associated Records (see 'Side Note' at the end of this post)
Clear(colParentQuestions);
ForAll(
RenameColumns(
colAssociatedQuestions,
"xxxx_questionid",
"rcQuestionID"
),
Collect(
colParentQuestions,
LookUp(
[@Questions],
Question = rcQuestionID
).ParentDCQuestion
)
)
I get the following error, specifically on the definition of the context variable 'locCurrentQuestionRecord':
"Multiple levels of many-to-one relationship expansion aren't supported"
I tried to avoid a lookup of a lookup (which I understand is not supported) by going this route with my logic above. Any assistance for working around this error would be appreciated. Thanks in advance.
Side Note: all this code exists in the OnSelect property of a button which, because of the aforementioned error, doesn't do anything when selected. If I copy/paste the button, without making any changes to the code, the code (and subsequent code built off these collections) executes exactly as anticipated for several minutes before the error is identified in the recently-pasted button.

Report
All responses (
Answers (