Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save msrivastav13/7e3e89d68cea572941caae5a3b9010e0 to your computer and use it in GitHub Desktop.
Save msrivastav13/7e3e89d68cea572941caae5a3b9010e0 to your computer and use it in GitHub Desktop.
Boost Your Developer Productivity with Modern Tools

Code Builder

Sign up for a Salesforce org

  1. Follow the instructions of your instructor to get a Salesforce org provisioned with Code Builder.

  2. Make sure you write down your user id and password. You'll need them again later in this workshop.

  3. In your browser, go to login.salesforce.com and log in to your org.

Enable and launch Code Builder

Step 1: Launch Code Builder

  1. Click the Setup icon (gear icon in the upper right corner), and click Setup.

  2. In Quick Find, search for Code Builder, and select Code Builder.

  3. Dismiss the error message. This is due to the pre-installation of Code Builder.

  4. Click the Enable Code Builder toggle to enable Code Builder. Review and accept the license agreement.

  5. Click the App Launcher icon (waffle icon in the upper left corner), and select the Code Builder app.

  6. In the Code Builder Dashboard, click the Launch button.

TIP: It will take a few minutes for Code Builder to fully initialize. Wait for the Let’s Get You Started page to appear before you continue.

Step 2: Create an SFDX Project

  1. Open the command palette (Press CMD+SHIFT+P on Mac or CTRL+SHIFT+P on PC).

  2. Search SFDX and Click on SFDX: Create Project with Manifest

  3. Click Standard

  4. Enter MODERN_TOOLS_WORKSHOP for the project name and press Return.

The project will now load and next we authorize as shown below.

Step 3: Authorize your Org

  1. You need to connect Code Builder to your org to be able to deploy code:

  2. Open the command palette (Press CMD+SHIFT+P on Mac or CTRL+SHIFT+P on PC).

  3. Search for Authorize an Org. If it is not yet available, wait Code Builder to fully initialize. If this command is not available please follow the steps below to create a new project.

  4. Select SFDX: Authorize an Org.

  5. Select Project Default.

  6. Enter MODERN-TOOLS-WORKSHOP for the org alias and press Return.

  7. Click Connect.

  8. Log in to your org using your credentials.

  9. Click Allow.

  10. Click Continue.

Retrieving Metadata from the Development Org

Retrieving Custom Objects Metadata Using Org Browser

Step 1: Open the Org Browser:

1 In the VSCode Activity Bar, click on the Salesforce icon to open the Org Browser.

Step 2: Expand the Metadata Types:

  1. In the Org Browser panel, expand the metadata types by clicking on the dropdown arrows.

Step 3: Locate Custom Objects:

  1. Scroll down and locate the CustomObject metadata type.

Step 4: Retrieve Custom Objects Metadata:

  1. Click on the CustomObject metadata type to view all custom objects available in your org.
  2. Click the download icon (cloud with a down arrow) at the top of the Org Browser panel to retrieve the selected custom objects' metadata.

Step 5: Confirm Retrieval:

  1. The metadata will be retrieved and stored in your project's force-app/main/default/objects directory.

Create an Apex Class PersonalizedExperiencesController

Open the Command Palette:

  1. Press Ctrl+Shift+P (Windows) or Cmd+Shift+P (Mac).

Create Apex Class:

  1. Type SFDX: Create Apex Class and select it.

Provide Class Details:

  1. Enter PersonalizedExperiencesController as the class name.
  2. Select the default directory for the class (usually force-app/main/default/classes).

4. Confirm Creation

  1. The new PersonalizedExperiencesController class file will be created and opened in the editor.

Einstein for Developers (Beta)

Activate Einstein for Developers

Screenshot 2024-07-17 at 9 06 51 AM

Create a Prompt to generate the Apex class

Generate a class PersonalizedExperiencesController with method name getMatchingExperiences. The method has a parameter of contact Id and the method fetches Experience records matching type field by fields Interest1__c or Interest2__c or Interest3__c from the contact record. Keep the query static

Screenshot 2024-07-17 at 9 32 58 AM

Code Analyzer

Install Code Analyzer CLI Plugin

  1. Open the Integrated Terminal:
    • Using the Menu:
      • Click on View in the top menu bar.
      • Select Terminal from the dropdown menu.
    • Using Shortcut Key:
      • Press Ctrl + Shift + ` on your keyboard.
    • Using Command Palette:
      • Press Ctrl + Shift + P to open the Command Palette.
      • Type Toggle Integrated Terminal and select it from the list.
  2. Run the below command in the terminal

sf plugins install @salesforce/sfdx-scanner

Install Code Analyzer VSCode Extensions

  1. Open the Extensions View:

    • Using the Sidebar:
      • Click on the Extensions icon in the Activity Bar on the side of the window. It looks like a square icon.
    • Using Shortcut Key:
      • Press Ctrl + Shift + X (Windows) or Cmd + Shift + X (macOS) on your keyboard.
  2. Search for the Extension:

    • In the Extensions view, there is a search bar at the top.
    • Type Salesforce Code Analyzer into the search bar and press Enter.
  3. Select the Extension:

    • From the search results, locate the "Salesforce Code Analyzer" extension.
    • Click on the extension to view its details page.
  4. Install the Extension:

    • On the extension’s details page, click the Install button.
    • Wait for the installation to complete. You will see a progress indicator and a message once the installation is finished.
  5. Activate the Extension:

    • Some extensions might require you to reload VSCode to activate. If prompted, click the Reload button or restart VSCode manually.

Scan for Code Vulenrability

Screenshot 2024-07-17 at 9 19 26 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment