For the most part, Entity Lists try to mirror the functionality of the selected model-driven form in CDS. This means that certain settings on the model-driven form can have a significant impact on how things work in Power Apps Portals, event if it is not obvious at first. In this post, I’ll cover one of those not-so-obvious (at least to me) settings – Show Related Records.
A little while back someone was asking on the D365UG forums about customizing the popup that appears when editing Portal Comments via the Timeline control. Unfortunately, the modal popup to edit comments is hard-coded when using the Timeline control, so the customization options are limited. One suggested work around is to used a standard subgrid, which provides a few more options (but doesn’t display in quite the same way as the Timeline control).
Whenever you do anything with activities (Portal Comments are a custom activity type), things can get weird, so before suggesting a subgrid, I wanted to try it out. I was able to quickly add a subgrid, and configured the ability to create new records using Entity Form Metadata. Entity Form Metadata allows you to add a create button to your subgrid, which can popup an Entity Form in a modal popup. Since now we’re dealing with Entity Forms, we can configure the form for creating Portal Comments. Great!
The problem I ran into is that after I created the record, it didn’t appear in my subgrid. I checked in CDS and found that while the record was created, it wasn’t related to my original record (in my situation, a Case record). What gives?
After a lot (too much, probably) of poking around through the Xrm Portal Community Edition code, I was finally able to track down the issue: I hadn’t selected the Show related records option when configuring my subgrid on the model-driven form.
Without that selected, the code doesn’t pass the type and ID of the current Case record to the popup (which is actually hosted in an
iframe, and the type and ID are passed via the query string). Without having those details the form doesn’t know which record to associate to and so it is created without that association, leading to an odd user experience where the record is created but doesn’t appear in the list from which it was created.
So, if you want the new record to be automatically associated with the current record, be sure to select the Show related records option on your subgrid configuration!