The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.

TRAP Method (TestPage)

Traps the next test page that is invoked and assigns it to the test page variable.




Type: TestPage

The test page variable that you use to refer to the test page.


You can trap only nonmodal pages with the TRAP method. To trap modal pages that you invoke with the RUNMODAL Method (Page) or the PAGE.RUNMODAL Method, you must use the ModalFormHandler method.


This example shows how to use the TRAP method to trap a call to open a test page so that the opened page is assigned to a variable.

This example requires that you create the following variables.

Variable name DataType Subtype
CustomerCard TestPage Customer
CustomerStatistics TestPage Customer Statistics
CustomerStatistics.TRAP; // The next page that is invoked will be trapped and assigned to the CustomerStatistics variable.  
CustomerCard."Page Customer Statistics".INVOKE; // Invokes an action from the Customer Card page.   
CustomerStatistics."Balance (LCY)".ASSERTEQUALS(0); // Now that the CustomerStatistics test page is open, you can use the variable to test the page.