Execute Anonymous View

Force.com IDE is in a maintenance-only state. We still provide support for the product through our official channels, but updates prior to October 12, 2019 will be only for critical security issues that arise. On October 12, 2019, we will no longer provide support or updates of any kind for Force.com IDE. On that date, we will also begin archiving documentation and removing download links for the product. We recommend that you start migrating to Salesforce Extensions for Visual Studio Code or one of the great tools made by our partners. For more information, see The Future of Salesforce IDEs on the Salesforce Developers Blog.

Warning

The Force.com IDE Execute Anonymous view allows you to execute an anonymous block of Apex.

Anonymous blocks help you to quickly evaluate Apex on the fly, or to write scripts that change dynamically at runtime. For example, you might write a client Web application that takes input from a user, such as a name and address, and then use an anonymous block to insert a contact with that name and address into the database.

The content of an anonymous block can include user-defined methods and exceptions. It cannot include the keyword static.

You do not need to manually commit database changes made by an anonymous block. If your Apex script completes successfully, any database changes are automatically committed. If your Apex script does not complete successfully, any changes made to the database are rolled back.

After your anonymous block is executed on the server, the Results area in the Execute Anonymous view will display the following:
  • Status information for the compile and execute phases of the call, including any errors that occur.
  • The debug log content, including the output of any calls to the System.debug() method.
  • The Apex stack trace of any uncaught script execution exceptions, including the class, method, and line number for each call stack element.

Unlike classes and triggers, anonymous blocks are executed as the current user and can fail to compile if the script violates the user's object- and field-level permissions.

Note