Comments
While I agree that it should be improved so the customer can't forget this, I would prefer to keep the option to do it also the way it is today. I did have 2 customers in the last 10 years of implementing NAV/BC who needed this.
So a setting on location or inventory/warehouse setup to automatically post the item journal "calculate warehouse adjustment" function when posting the warehouse journal is my preferred solution.
I tried to get around this restriction by creating a page extension on the page that includes a text field that I can put a value in that will trigger the function to be called. I think you will agree this feels like a hack to get around the limitations of the platform.
This method does not allow the field to be set prior to opening the page, which means if my page checks to see if it has been initialised in an OnOpenPage trigger, it will still not work.
I figured I could raise an IsHandled type even before calling the code in the OnOpenPage so I could use a manually bound codeunit subscriber to force the page to not call the OnOpenPage code until I have had chance to use my field hack to call my initialise code. This requires changing the object under test too much.
One easy way to deal with this requirement would be to make it so that an instance of a Page object can be assigned to a TestPage and vice-versa. This would mean I could do the following:
RealPage.InitialiseValues(SomeValues);
TestPage := RealPage;
TestPage.Edit();
// do my automated test
RealPage := TestPage;
RealPage.GetSomeValues(SomeValues);
Either approach would work. At the moment I am stuck with an untestable page.