27
from closed https://github.com/microsoft/AL/issues/6440#issuecomment-792290006

related to this highly voted Idea, but IMO my proposal might be more comprehensive, although of course it could be great for both to co-exist as the other version of just using a property per extension (nor per record) would be easier for simpler cases - https://experience.dynamics.com/ideas/idea/?ideaid=db0e5a74-25c0-e911-b083-0003ff68d32d

--

There is currently no (good) way for extensions to 'override' the default `CardPageId`.

There is no way to specify a different `CardPageId` in a `pageextension` (but see [this idea](https://experience.dynamics.com/ideas/idea/?ideaid=db0e5a74-25c0-e911-b083-0003ff68d32d) and the AL issue linked therein). Moreover, even if there was, that would only let us specify a single card page ID per record type, but we might need a way to open different card pages depending on some field(s) of the specific record.

As it is, it looks like we can only work around this for totally custom pages, by setting no `CardPageId` in the base `page` to omit the standard New/View/Edit actions, creating our own ones to open the 'base' card, and adding `OnBefore` events to enable overriding by downstream extensions. This is obviously laborious, boilerplate, tedious, and worst: unusable if extending MS pages.

Can it be possible to get some kind of new 'system event', that will be automatically published by every `page` object, to which we can subscribe and override the `CardPageId` depending on the `Sender` record? Something like this publisher:

```al
local procedure OnBeforeOpenCardPage(Rec: Record; var CardPageId);
```

but automatically published by the system. The `var CardPageId` would default to the one from the base page (or the 'winning' extension if that Idea gets implemented) but could be changed by a subscriber based on the fields of the `Sender` record. Then the final `CardPageId`, which may or may not have been changed, would be used by all standard New/View/Edit/whatever actions.

The real type of `Rec: Record` will need to differ per page, matching its `SourceTable`, so a bit of magic seems to be needed there.

Thanks!
Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.

Best regards,
Business Central Team