At the moment there does not appear to be any events for you to subscribe to, that would help you solve the problem.
The first thing to do then is to submit a request to Microsoft to add the needed events to the product. Request New Events
That being said there is a workaround for your problem, which involves a few steps:
- Create a copy of Demand Forecast (Page 99000919).
- Code your required changes in your copy of the page
- Substitute the original page with your copy
The last step is achieved by identifying all places where the original page is opened and then overtaking the code.
There are three places where Demand Forecast is opened:
- Page 99000921, Demand Forecast Names, Action Edit Demand Forecast
- Page 8907, Sales & Marketing Manager RC, Action Forecast
- Codeunit 5530, Calc. Item Availability
1 and 2 are run non-modal which means in both cases you can do the following:
[EventSubscriber(ObjectType::Page, Page::"Demand Forecast Names", 'OnBeforeActionEvent', 'Edit Demand Forecast', true, true)]
local procedure Page_DemandForecastNames_OnBeforeActionEvent_EditDemandForecast(var Rec: Record "Production Forecast Name")
var
DemandForecastCopy: Page "Demand Forecast"; // this variable should reference your copy
begin
DemandForecastCopy.SetProductionForecastName(Rec.Name);
DemandForecastCopy.Run();
Error(''); // this creates a silent error which cancels the original execution of the action.
end;
SetProductionForecastName
should not be called for "Sales & Marketing Manager RC".
The third one is a bit trickier because the page is run modal from the codeunit, but since we have now replaced all occurrences where the page is run non-modal, we can now assume that every time the original Demand Forecast is opened it should be modal.
Unfortunately subscribing to the Demand Forecast OnOpenPageEvent
won't help you because there are no parameters to get values from. So you have to backtrack the code from Calc. Item Availability
to find all possible entry points and then override the default implementation as described earlier.