Anonymous Apex is an excellent tool for testing new functionality or debugging your code without building this code to the org. The Anonymous Apex helps you to get detailed logs and to check new development approaches.
Executing Anonymous Apex
To execute Anonymous Apex do the following:
- write the code that you want to test,
- click on the Execute Anonymous Apex button.
As a small nice bonus, you can run Anonymous Apex directly from an Apex file: select the code in the editor, right-click on it, and find a new command Execute selected code as Anonymous Apex. No new files creation, no additional typing or copy / paste, just several clicks.
You can explore the log related to this code execution right after it is finished. To do so, check the box Open execution logs at the top right corner of the editor. As soon as the code is executed, you will get the log file opened in the Debug Logs Viewer. The option
Open execution logs remembers its last state in the current session, so the setting is kept the same that you've selected previously. When you start the new session in The Welkin Suite, the setting for this option returns to the default state — the filter is unselected.
Errors in Anonymous Apex
The Welkin Suite handles all the errors when running Anonymous Apex. Execution errors are displayed in the Error List Panel, so you can check the reason for a fail and quickly revise your code.
Organizing the Anonymous Apex
You can easily store the parts of the code for different purposes (for example, debugging, interacting with outer services, etc.) in the separate files. In The Welkin Suite, you are able to create an unlimited amount of
.anonymous files and organize them as you want: create appropriate folders and logically group them.
In this section:
This also may be helpful: