Apex · Salesforce

Apex Interactive Debugger

The Apex Interactive Debugger is a developer tool to debug our code step by step (like .net and java Breakpoint). You can see the real time variable result in Force.com IDE in Eclipse. It is generally available now.

If your organization has purchased debugging capability, all of the sandboxes spawned from it are enabled for debugging. The number of sessions you purchase represents the number of your sandboxes that can be debugging at the same time.

Pros:

  1. You can use this feature in all your sandbox(Full, Partial, Developer).
  2. Assign “Apex Dubug” permission to user via PermissionSet
  3. Use Force.com IDE in Eclipse to start debug
  4. Set breakpoint any line of apex class and trigger and Test class.

Cons:

  1. Debugger session not available on production instance.
  2. Only Eclipse with Force.com IDE supported
  3. Does not work for Batch Apex and Scheduled Job
  4. Can’t set breakpoint in Visualforce Page.
  5. 1 debugger session at a time per sandbox org.

Note: Need to contact Salesforce to enable this feature(not feature license). There is cost involved.

How to setup Apex Debugger in your sandbox?

Step 1: Contact Salesforce to enable the Apex Debugger

Step 2: Install/Update the Force.com IDE in your eclipse

screen-shot-2016-11-16-at-2-46-42-pm

  • Click Next and proceed with the installation.

Step 3: Create Permission Set

  • Create a permission set. Give it a name that you can remember, such as Debug Apex.
  • In the “Select the type of users who will use this permission set” section, choose
  • None from the User License drop-down list. Choosing None lets you assign the permission set to more than one type of user.
  • Save your changes.
  • Click System Permissions.
  • Click Edit.
  • Enable the Debug Apex permission.

screen-shot-2016-11-16-at-2-36-40-pm

  • Save your changes.
  • Click Manage Assignments.
  • Click Add Assignments.
  • Select the users to whom you want to assign the permission set, and then click Assign.

Step 4: Create project in Eclipse

  • In Eclipse, select File | New | Project | Force.com | Force.com Project | Next.
  • Enter a descriptive project name and your Salesforce sandbox org’s credentials. Choose Sandbox from the Environment drop-down menu.

screen-shot-2016-11-16-at-2-43-33-pm

  • Once Project is created – Select “work Online”. Right click Project –> Force.Com | Work Online.

screen-shot-2016-11-16-at-2-44-00-pm

Step 5: Debugger setup on Eclipse

  • choosing Window | Open Perspective | Other | Debug.
  • Click the debug icon debug icon in the toolbar and select debug configurations.

screen-shot-2016-11-16-at-2-52-21-pm

  • Select Remote Apex Debugger.
  • To create a configuration for your project, click the New launch configuration icon.

screen-shot-2016-11-16-at-2-54-58-pm

  • Name the configuration.
  • Click Browse and select your project.

screen-shot-2016-11-16-at-2-59-10-pm

  • Click Apply, and then click Debug.
  • Wait for few min and go to Debug window and see below yellow gear available on your newly created Debugger.

204

  • To set breakpoint, Go to controller or trigger double click before row number.

screen-shot-2016-11-16-at-3-13-03-pm

  • Go to salesforce UI and execute business process then you will see the UI stopped there and your Eclipse will have session .
  • The Debugger stops at the breakpoint (1). The call stack (2) and the values of your variables (3) are displayed.

2041

 

One thought on “Apex Interactive Debugger

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s