+ Start a Discussion
Georg WilleGeorg Wille 

VS Code: Execute Anonymous Apex with Currently Selected Text stopped working

I am not sure this is the right forum for my issue; if it isn't, could someone please direct me to the correct person / team / instance.

The command SFDX: Execute Anonymous Apex with Currently Selected Text has stopped working. It returns the following error message:
  • Command 'SFDX: Execute Anonymous Apex with Currently Selected Text' resulted in an error (command 'sfdx.force.apex.execute.selection' not found)
Subsequent attempts to execute the command simply produces no output in the OUTPUT window, together with a succes or failure message, depending on whether my code comiles or not.

On the other hand, SFDX: Execute SOQL Query with Currently Selected Text  still works as expected:
 
My Visual Studio Code displays the following in Help > About
Version: 1.53.2 (user setup)
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:48:04.245Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042
Best Answer chosen by Georg Wille
Tony Eggers 10Tony Eggers 10
Anderas Wawer ... Look here: github.com/forcedotcom/salesforcedx-vscode/issues/2947.  Apparently they changed output to be displayed using "Apex Extension" versus "Salesforce CLI".

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi George,

Greetings!

This could be because of the latest release issue so,I would suggest you to follow the below thread for the workaround.

https://github.com/forcedotcom/salesforcedx-vscode/issues/2369

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
Georg WilleGeorg Wille
Hello Shirisha

The issue 2369 you directed me to seems to be about a problem with the command SFDX: Execute Anonymous Apex with Editor Contents, whereas my problem is about the similar command SFDX: Execute Anonymous Apex with Currently Selected Text.

The first one I have known about for some time (it isn't fixed as far as I can see, contrary to what the issue page says, or there is now a related problem) - it didn't matter much because one could alwas use the selected text variant; now I have no way of executing anonymus apex any longer.

But Thank you for the link - I will try and report my issue there. 
Andreas WawerAndreas Wawer
I have the same issue here. 
SFDX: Execute Anonymous Apex with Currently Selected Text 
   
simply does not result in anything in the OUTPUT Tab. The 
SFDX: Execute SOQL Query with Currently Selected Text
   
works fine. 
Tony Eggers 10Tony Eggers 10
Same issue here ... Just started today. I can execute via sfdx force:apex:execute -f on the cmd line and I get out in terminal. But nothing from the editor using the command palette.
-------------------------------------------------
SFDX: Execute Anonymous Apex with Currently Selected Text 
    simply does not result in anything in the OUTPUT Tab. The 
SFDX: Execute SOQL Query with Currently Selected Text
   works fine. 
Tony Eggers 10Tony Eggers 10
Anderas Wawer ... Look here: github.com/forcedotcom/salesforcedx-vscode/issues/2947.  Apparently they changed output to be displayed using "Apex Extension" versus "Salesforce CLI".
This was selected as the best answer