You need to sign in to do that
Don't have an account?
Saurabh Sarpotdar
Using Execute Anonymous Window to execute an apex class..!!
I have a very basic question. Through Force.com developer console I created a new apex class..say xyz.apxc then I wrote my code and saved my class..now I want to run that class using Developer console.. how I can do that..? Please tell me how can I use System.debug to execute my class...What will be the steps..?
To execute your class follow the steps below:
1) Click Debug. | Open Execute Anonymous Window or CTRL+E.
2) In the Enter Apex Code window, call the method with the name of the class if method is static
3) Click Execute
If you want to see debug log then select Debug Only option
Regards,
Ajay
I want execute List , so how can i do it??
This is how we create a list
Here list strores string data type and add is method of list which stores values. We use system.debug to print value in debug log. Copy code in your org to see how it works
To read more about it check
List in Apex (https://www.sfdcamplified.com/2018/11/list-methods-in-salesforce-with-interesting-examples.html)
Scenario - Create a new apex class with name apex, write code and save it. Run class in developer log.
Image
Code for class
Code for anyonymous window
Explaination
1. Go to Developer Console
2. Go to File -> New -> Apex Class -> Put class name as 'Apex'
3. Write the above code. This code has class name 'Apex' and method name 'myName'
4 It contains sytem.debug, which is used to print the value in debug log
5. Go to Debug -> Open Execute Anonymous Window
6. Paste the second code. It contains class. method name
7. Click Execute
8. Click Debug log
Output
To understand more basics go to below link:
sfdc Amplified (https://www.sfdcamplified.com/)