Finally, Salesforce brings Debugging feature. I was waiting for this one for a long time and I am quite sure that many other developers like me also waited for this one.
Today in this post, I would like to explain how you can use this feature and make your Salesforce developer life more powerful.
Before I start, I would like to mention that this feature is not available in Developer orgs, it is only available in Sandboxes. You need to contact Salesforce to enable this feature in your Sandboxes. There is cost involved in getting this one enabled. To know about the cost, please contact Salesforce.
With the assumptions that you have enabled this feature in your Sandbox, you need to setup your Sandbox as well as your Eclipse workplace. Below are the steps mentioned in Salesforce guide –
Setup Sandbox for Apex Debugger –
Setup Force.com IDE –
- First you need to Install or Update Force.com IDE plugin as instructed below –
- Once done, create a Salesforce project as instructed here. Note – Make sure you mark your Eclipse project as work online.
Setup Eclipse Debugger –
This is the most important step where you need to setup your Eclipse Debugger. To do that –
- Click on the Debug Icon in the toolbar and select Debug Configuration.
- Select Remote Apex Debugger
- Click on the New Launch Configuration Icon
- Give some name of your configuration
- Click Browse and select your project
- Click Apply, and then Debug.
Once you are done with the above steps, your basis setup is done and you are ready to use Apex Debugger. So let’s use now.
I have created one very basic Apex class to start with. The code is below –
Now let’s follow the below steps to do the debugging –
- Setup breakpoint @ line # 3, 7 and 12. Intention is that we will see the values of the variables during the execution flow. You can setup breakpoint by double clicking on the line numbers
- Open the Debug perspective by choosing Window | Open Perspective | Other | Debug
- Click on the Debug icon and launch the new debug configuration (created earlier) You will get yellow gear icon indicating that your debug session is ready.
- Let’s execute the below code from Developer console’s Execute Anonymous Window – new SudiptaDeb_ApexDebug_Demo().method1(‘Sudipta Deb’);
- Once you start that you will see that in Eclipse the executing is waiting at your first breakpoint as shown below –
- Watch the value of the variable as shown below –
- Click on Step Over icon you will see the execution is now moved to second breakpoint. Watch for the value now as shown below –
- Again click on Step Over icon you will see the execution is now moved to third breakpoint. Watch for the value now as shown below –
Great!!! In my next post, I have explained some of the more advanced features of Apex Debugger. Till then, feel free to post your comments and let me know how you feel about this great feature from Salesforce. Have a nice day.