Anonymous Apex

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.

In The Welkin Suite, Anonymous Apex is treated similarly to the usual Apex code with all the supported features for Apex Code Assistance.

Executing Anonymous Apex

To execute Anonymous Apex do the following:

  1. open any .anonymous file or create a new one via the Add new item option in the Solution Explorer,
  2. write the code that you want to test,
  3. click on the Execute Anonymous Apex button.

Executing Anonymous Apex

If you already have a saved Anonymous Apex file, you can execute it without opening. In the Solution Explorer, right-click on a necessary Anonymous Apex file and select the Execute Anonymous Apex option from its context menu.

Execute your Anonymous Apex files without opening them

The file won't be opened itself, but its execution log file will be shown after the execution is finished. The log file opening, in this case, isn't related to the 'Open execution logs' setting which is present in the Anonymous Apex file when it is opened.

In cases, when you have lots of different functionality snippets in one anonymous file, or just want to test only a part of the code, use the Execute highlighted option. Select the necessary code lines and click on the Execute highlighted button.

Execute highlighted

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.

Organizing the Anonymous Apex

In this section:

This also may be helpful:

Last modified: 2017/05/24 11:30

footer image