Slaesforce FAQ

how to create a checkpoint in visual studio code salesforce

by Rogers Rempel Published 2 years ago Updated 2 years ago
image

Open the Apex class or trigger in the Source Code Editor. Click in the margin to the left of the line number where you want to set the checkpoint. You can enable up to five checkpoints at the same time.

Set Breakpoints and Checkpoints#
  1. Set checkpoints on up to five lines in Apex classes or triggers.
  2. Click the line of code where you want to set the checkpoint.
  3. Open the command palette (press Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS).
  4. Run SFDX: Toggle Checkpoint.

Full Answer

How do I set checkpoints in Salesforce?

Note: To set checkpoints, you need the View All Data user permission. To generate results using checkpoints, run code using execute anonymous, or set a DEVELOPER_LOG trace flag on yourself. The trace flag must have a log level for Apex of INFO or higher.

How do I use checkpoints in Visual Studio Code?

When your code is displayed in the source code editor, you can see line numbers on the left side. Click the line number for inspectResults (results);. A red dot (1) appears, indicating that a checkpoint has been created. Now you can execute your code and analyze it using the Checkpoints tab.

How do I use Visual Studio Code with Salesforce CLI?

Like with any good development tool, there is more than one way to do things with Visual Studio Code. The two main ways you can interact with Salesforce CLI are through the integrated terminal or quick open window. To view the quick open window, press Command + P on Mac or Ctrl + P on Windows.

How do I check if a checkpoint has been created?

When your code is displayed in the source code editor, you can see line numbers on the left side. Click the line number for inspectResults (results);. A red dot (1) appears, indicating that a checkpoint has been created.

image

How do I use checkpoints in Salesforce Developer Console?

Set Checkpoints in Apex CodeOpen the Apex class or trigger in the Source Code Editor.Click in the margin to the left of the line number where you want to set the checkpoint. ... Execute the code with the Developer Console open.View your checkpoints and results on the Checkpoints tab.

How do I use debug console in Vscode for Salesforce?

Run Apex Tests and Get Debug LogsIn Visual Studio Code, click the View menu then choose Command Palette.... ... Enter sfdx replay in the search box, then choose SFDX: Turn On Apex Debug Log for Replay Debugger. ... Open the Command Palette and enter apex test in the search box, then choose SFDX: Run Apex Tests.More items...

How do I create a debug log in Salesforce?

Set a user-based trace flag on the guest user.From Setup, enter Debug Logs in the Quick Find box, then click Debug Logs.Click New.Set the traced entity type to User.Open the lookup for the Traced Entity Name field, and then find and select your guest user.Assign a debug level to your trace flag.Click Save.

How do you run a test class in VS code?

To access the Test view, click the beaker icon ( ) in the Activity Bar on the left side of the VS Code editor. If you don't see this icon, make sure that the project contains an sfdx-project. json file in its root directory.

How do I configure Visual Studio Code in Salesforce?

How to Setup Visual Studio Code for SalesforceStep 1) Download and Install VsCode.Step 2) Install Salesforce DX CLI.Step 3) Install Salesforce Extension Pack.Step 4) Create Project.Step 5) Connect with your Salesforce Org.Step 6) Retrieve Component.Step 7) Deploy component.Recording.

How do I start debugging in Visual Studio Code?

Once you have your launch configuration set, start your debug session with F5. Alternatively, you can run your configuration through the Command Palette (Ctrl+Shift+P) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug.

How do I debug a code in Salesforce?

Use checkpoints, logs, and the View State tab to help debug the code you've written.Set Checkpoints in Apex Code. Use Developer Console checkpoints to debug your Apex classes and triggers. ... Overlaying Apex Code and SOQL Statements. ... Checkpoint Inspector. ... Log Inspector. ... Use Custom Perspectives in the Log Inspector. ... Debug Logs.

How do I create a log file in Salesforce?

The Salesforce Event Log File (ELF) Browser is a Salesforce-connected web app that allows quick access to event log files....View Events in Salesforce Event Log File BrowserLog in to your org.Click Production Login.Set the start Date.Select an event type for your search, or leave event type set to All.Click Apply.

How do I debug a test class in Salesforce?

Go to Setup>Developer>Apex Test Execution>Select Tests> pick the testing class you want to see the debug logs from can click run.

How do you run a class in VS Code in Salesforce?

There are different way to setup VsCode by ForceCode Extensions or SalesforceDx. Here is agenda of our session. Install Salesforce Extension Pack. Run Test Class : To retrieve code coverage results when you run Apex tests, edit your workspace settings and set salesforcedx-vscode-core.

How do I create a test report in Visual Studio?

To generate unit tests, your types must be public.Open your solution in Visual Studio and then open the class file that has methods you want to test.Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.

How do I run a test class in Salesforce?

To run tests for an individual class from Setup, enter Apex in the Quick Find box, then select Apex Test Execution. Click Select Tests, select the classes containing the tests you want to run, and then click Run.

Follow Along with Trail Together

Want to follow along with an instructor as you work through this step? Take a look at this video, part of the Trail Together series on Trailhead Live.

Terminal Versus Command Palette

Like with any good development tool, there is more than one way to do things with Visual Studio Code. The two main ways you can interact with Salesforce CLI are through the integrated terminal or quick open window.

Create a Project

Press Command + Shift + P on Mac or Ctrl + Shift + P on Windows to make the command palette appear.

Search your Files

Press Command + P on Mac or Ctrl + P on Windows to make the search palette appear. This shifts the focus to search files.

Authenticate to Your Playground

Press Command + Shift + P on Mac or Ctrl + Shift + P on Windows to make the command palette appear.

Create an Apex Class

Click the Explorer icon in Visual Studio Code to expand the force-app folder.

Query

Our new Apex class has a SOQL query in it, but we want to make sure it works as we expect before we deploy it to our org. We use the command palette to run the query against our org.

Checkpoints

This list displays the checkpoints currently available for review. Select Debug | My Current Checkpoints Only to only display checkpoints you’ve created since opening the Developer Console. Deselect this option to display all checkpoints currently saved for your organization, including newly-generated ones created by other users.

Checkpoint Locations

This list provides the location of each checkpoint in the source code. Each item in the list displays this information:

Set Checkpoints in Your Apex Code

The moment your spaceship starts sounding system errors, you have to head straight to the logs to figure out what went wrong and where.

Checkpoints Tab

You can view exactly where your code’s execution is going wrong, and what the values of the objects are at that point, using the Checkpoints tab. Let’s run this code to see the checkpoint in action.

Heap Tab

The Heap tab includes some great panels for debugging, like the Types panel. This panel shows how many objects were instantiated and the memory they consumed in bytes. Let’s look at the details captured by the checkpoint you set.

Symbols Tab

The Symbols tab is a quick and simple way to review the states of various objects at any checkpoint. Symbols are unique names that reference particular objects. The tab displays all symbols in memory using a tree view.

Hands-on Challenge

You’ll be completing this challenge in your own hands-on org. Click Launch to get started, or click the name of your org to choose a different one.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9