The Code Editor module is a quick and easy to use tool which allows you to execute anonymous Apex, create and edit existing Apex Classes, Triggers, Pages and Components.
You can add, edit, or delete Apex using the Code Editor module only in a Developer Edition organization, a Salesforce Enterprise Edition trial organization, or sandbox organization.
To create a new file or open an empty anonymous Apex script, click on the + or New button. After that, select which file type you would like to create and give it a name, then press Create.
If you wish to open an already existing file, choose the file type from the dropdown and select the desired file. The file collection also features an integrated search box, facilitating easier navigation.
When you are done writing your anonymous script, you can run it by pressing Execute or CTRL / CMD + Enter. Execution results will show up on the bottom of the module. To check out the full results of the execution, go to the Debug Logs module.
While the script is executing a tab spinner will appear. You are free to leave the tab or change the module during execution as it is asynchronous.
If you want to store an anonymous script locally for future use, click Save while it is open. Give your script a name and it will be stored in the collection.
After successfully executing a script, it will be stored under Recent Scripts while the session is active.
The buttons for revealing these collections are located in the top right of the module, in the second row.
These buttons represent:
After editing an existing file, its tab will show an orange dot which indicates that changes have been made.
When you are done editing the file and would like to deploy it to your org, click Save with the desired tab opened. This will create or reuse an existing MetadataContainer and it will create a new ApexMember depending on the file type. Then, a ContainerAsyncRequest will be issued and your org will either accept or deny the new changes, depending on the compilation and deploy status. During this process a spinner will appear and you will be able to leave the tab or module without issue.
Before this process begins, Maven Tools will check whether the file has been modified in the meantime.
Also, if you try to close a tab with unsaved changes, Maven Tools will warn you and give you an opportunity to save your work.
If the save fails, error messages will be written out on the bottom of the module.
To delete a file or a script, click on the first button in the second row while the tab is opened or the trashcan icon which appears when you hover an item in the collection panels.
Before confirming your delete, you are able to backup the file in a .txt format from the modal.