EXPERIMENTEXP-04
DATASETSalesforce Cloud
VIVA ITEMS04 questions
LAB NOTEBOOKnone

Cloud Application Development with Apex

Develop Apex classes and execute anonymous blocks in the Salesforce cloud Developer Console.

#Salesforce#Apex#SaaS#PaaS#Developer Console
Option Value
Prerequisites Salesforce Developer Org Account
Estimated Time 25 minutes
Technology Salesforce Platform, Apex (Proprietary Cloud Language), Developer Console

🎯 Aim

To set up a Salesforce Developer Environment, create a custom Apex Class, compile it on the Salesforce Cloud, and execute it using the Developer Console’s Anonymous Execution Window to view debug logs.


📖 Theoretical Background

Salesforce.com Platform & Apex

Salesforce is a leading cloud-based Customer Relationship Management (CRM) platform. It provides Platform as a Service (PaaS) capabilities through its proprietary programming language, Apex.

Key Characteristics of Apex:

  • Cloud-based: Apex is compiled and executed entirely on Salesforce’s multitenant cloud servers. It is not run locally.
  • Object-Oriented: The syntax is highly similar to Java or C#.
  • Strongly-typed & Database-integrated: Apex integrates directly with the Salesforce database (SOQL/SOSL queries and DML operations can be written directly within the language).
  • Governor Limits: Because Apex runs in a shared multitenant environment, Salesforce enforces strict “Governor Limits” (e.g., maximum CPU time, maximum SOQL queries) to prevent a single user’s script from hogging shared system resources.

🛠️ Requirements & Setup


🚶 Step-by-Step Procedure

Phase A: Setting up and Accessing the Console

  1. Sign In: Navigate to login.salesforce.com and enter your Developer Org credentials.
  2. Launch Developer Console:
    • In the Lightning Experience interface, click the Gear Icon (Setup) in the top-right corner.
    • Select Developer Console from the dropdown menu. A separate IDE window will open.

Phase B: Writing the Apex Class

  1. Create Class: In the Developer Console, go to File ➔ New ➔ Apex Class.
  2. Name Class: In the prompt box, enter the class name HelloWorldApp and click OK.
  3. Write Code: Replace the default generated code structure with the following:
    public class HelloWorldApp {
        public static void sayHello() {
            System.debug('WELCOME TO APEX PROGRAMMING');
        }
    }
  4. Save and Compile: Go to File ➔ Save (or press Ctrl + S). The Developer Console will compile the code on the cloud. Check the Problems tab at the bottom to ensure there are no compilation errors.

Phase C: Executing the Class

  1. Open Anonymous Window: In the Developer Console, click on the Debug menu at the top, then select Open Execute Anonymous Window (or press Ctrl + E).
  2. Write execution script: In the dialog box, type the following Apex statement to invoke the static method:
    HelloWorldApp.sayHello();
  3. Execute: Ensure the Open Log checkbox is checked at the bottom right, and click the Execute button.

🧪 Expected Output & Verification

  • The Log Inspector window will load automatically showing details of the execution.
  • Check the Debug Only checkbox in the bottom filter panel.
  • The log list will filter down to display your output statement:
    |USER_DEBUG|[3]|DEBUG|WELCOME TO APEX PROGRAMMING

[SECTION: ORAL EXAMINATION LOG]

Viva Voce Study Guide

The following index represents standard conceptual questions asked during the practical assessment. Review the expected model answers below.

// EXPECTED RESPONSE:Apex is a strongly-typed, object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with calls to the API.