• WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG
    • WHO WE ARE
    • WHAT WE DO
      • Salesforce
        • Implementations
          • Sales Cloud
          • Service Cloud
          • CPQ
          • Field Service Lightning
          • Field Service for SMEs
        • Developments
          • Salesforce Customization
          • Custom Application Development
          • AppExchange Product Development
        • Migrations
          • Classic to Lightning Migration
          • Other Systems to Salesforce Migration
        • Integrations
      • Data Science
        • BI Solutions
        • AI/ML solutions
        • Agentic AI
    • HOW WE DO
      • Delivery Model
      • Our Works
    • REACH US
      • Contact Us
      • Careers
    • BLOG
  • [email protected]
  • (+91) 44-49521562
Merfantz - Salesforce Solutions for SMEs
Merfantz - Salesforce Solutions for SMEs
  • WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG

Developer Guide APEX – Data Types and Variables

  • January 5, 2023
  • Merfantz Editor
  • Salesforce Admin Tutorial
  • 0

Apex allows Salesforce developers to customize and create out-of-the-box solutions. A Salesforce developer is an individual who excels in the development of standard and custom Salesforce solutions using Apex programming. Overall, Apex allows developers to execute process flows and transaction control statements while witnessing API calls. In addition, it enables Salesforce customers to add custom functionalities to their reliable applications.

What Is Apex?

Apex is an object-oriented programming language and a proprietary language developed by Salesforce. It is a strongly-typed language. Moreover, it is effortless for strongly-typed languages to predict the nature of the behaviour of the written code. At first, Apex language allows you to write custom code examples and robust solutions executed on the Force.com platform. You can quickly build SaaS applications on top of Salesforce with the help of Apex.  It enables the Salesforce developer to add custom business logic to several events, including button on-clicks, current and related record updates, and triggering visual Force and Lightning pages.

However, enables you to add and interact with data in the Lightning Platform persistence layer.  In brief uses classes, data types, variables, and if-else statements. A developer  make it execute based on a condition, or have a block of code execute repeatedly.
  • Data Types and Variables
  • Control Flow Statements
  • Working with Data in Apex

 Apex Developer Guide  in detail

Variables in Salesforce

Variables in Salesforce Apex are the same as the variables in java which acts as a container to store data. Whereas  in Salesforce we have some extra data types which are like sObjects which stores the record of a particular Salesforce object.

Data Types in Salesforce

1. Primitive Data Types

In general, primitive data types in Salesforce are “Integer”, “String”, “Double”, “Long”, “Date”, “Date time”, “Boolean” and one more interesting data type which is “Id” to store the unique id of the records.

Example (Integer)

Then “System .debug()” in particular is used for debugging or printing the value on the developer console in Salesforce.

Example (Date)

2. sObject

sObjects are very interesting kind, they store the records of any particular salesforce objects. However, we just need to specify the object name as the data type.

Example (sObject)

Thereafter, try this out in the developer console and the output is:

3. A collection

A collections is a type of variable which can store multiple data. In salesforce we generally use this to store multiple records. They are of three types list, set and map.

i) List

Firstly, a list stores multiple data with an ordered index starting from 0 and repeated values are allowed. Let’s take a simple example of lists.

For example:

ii) Set

A set stores multiple data with an unordered index and unique values are allowed. Let’s take a simple example of sets.

For example:

iii) Maps

In detail maps are different. It stores the multiple data of key and value pairs. Here each value has a unique key. Both can be of any data types.

For instance:

4. Enums

In simple Enums are user defined data types.  Developers can also store predefined values in that data type. Now when you try to store any other value in that variable it shows error.

Example:

Now after creating this class, developers  can declare any variable with this “week” data type and the values assigning to them should only be one of these “SUN, MON, TUE, WED, THUR, FRI, SAT” like, week x = week.SUN;

5. Classes

A class is a blueprint for an object which consists of all the methods and variables. Apex classes are similar to java classes.

In order to create a class in Force.com

  • pen developer console
  • click file
  • thirdly, click new
  • click Apex class
  •  Enter the name of the class
  •  click OK,

6. Objects

Objects are the instance of a class in simple. In salesforce we can also create objects of sObjects which is simple.

7. Interfaces

An Interface is similar to class but the difference is in class developers provide the methods body but in Interface we provide only method names but not body we have to implement them to our classes and then we have to write the method body.

8. Null

Null is a reserved word in apex. When you create a variable without initializing anything to it then the variable stores null. Also when you initialize the value with a word null then also the variable stores null. However “stores null” means stores nothing or empty.

 

For More Blogs: Click Here

Author Bio

Merfantz Editor
+ Recent Posts
  • August 4, 2023
    How to Setup CRM Analytics for Financial Services Cloud
  • August 2, 2023
    How to Get Started with Salesforce Hyperforce - Merfantz
  • July 28, 2023
    Health Cloud Mastery: Salesforce Trailhead for Effective Healthcare CRM
  • July 26, 2023
    How to integrate Data cloud and Marketing cloud In Salesforce
  • Previous Aura Components Vs Lightning Web Components
  • Next Top Benefits using Salesforce CDP with Merfantz
Merfantz Technologies is a leading Salesforce consulting firm dedicated to helping small and medium enterprises transform their operations and achieve their goals through the use of the Salesforce platform. Contact us today to learn more about our services and how we can help your business thrive.

Discover More

Terms and Conditions
Privacy Policy
Cancellation & Refund Policy

Contact Info

  • No 96, 2nd Floor, Greeta Tech Park, VSI Industrial Estate, Perungudi, Chennai 600 096, Tamil Nadu, INDIA
  • (+91) 44-49521562
  • [email protected]
  • 9:30 IST - 18:30 IST

Latest Posts

Mastering Attachment Compression for Salesforce Developers May 9, 2025
Salesforce API Integrations: Connect with Slack, Zoom, and Teams May 2, 2025
Guide to Streamlining Sales Success
Mastering Salesforce CPQ: A Comprehensive Guide to Streamlining Sales Success April 17, 2025

Copyright @2023 Merfantz Technologies, All rights reserved