VS Code Useful Tips

If you want to execute some apex code, you either use developer console or workbench. It is always a pain to connect workbench with login credentials since it become inactive after being idle. Moreover, the code or query executed is not saved and you need to write it again.

VS Code has a useful feature to Execute Apex anonymou code from Visual Studio Code

  1. Open a new file

2. Write your code you want to execute like as shown below

3. Click Control+Shift+P or Click View->Command Palette and choose SFDX > Execute anonymous Apex with Editor Contents

The code will execute and shown on the output window

You can save the temp file if you want to run it later.

Moreover, if your file has a lot of code, you can select a part of it and using the same command, only selected/highlighted part will execute.

Permanent link to this article: https://salesforcebuddy.com/2020/04/vs-code-useful-tips/

Leave a Reply

Your email address will not be published.