• WHO WE ARE
  • WHAT WE DO
    • Implementations
      • Salesforce
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service for SMEs
        • Field Service Lightning
      • Salesforce Partner Apps
        • Panda Doc
        • Conga
    • Developments
      • Salesforce Customization
      • Custom Application Development
      • AppExchange Product Development
    • Migrations
      • Classic to Lightning Migration
      • Other Systems to Salesforce Migration
    • Integrations
  • HOW WE DO
    • Delivery Model
    • Our Works
  • BLOG
    • WHO WE ARE
    • WHAT WE DO
      • Implementations
        • Salesforce
          • Sales Cloud
          • Service Cloud
          • CPQ
          • Field Service for SMEs
          • Field Service Lightning
        • Salesforce Partner Apps
          • Panda Doc
          • Conga
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • HOW WE DO
      • Delivery Model
      • Our Works
    • BLOG
Salesforce Blog | Salesforce Simple Tutorial
Salesforce Blog | Salesforce Simple Tutorial
  • WHO WE ARE
  • WHAT WE DO
    • Implementations
      • Salesforce
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service for SMEs
        • Field Service Lightning
      • Salesforce Partner Apps
        • Panda Doc
        • Conga
    • Developments
      • Salesforce Customization
      • Custom Application Development
      • AppExchange Product Development
    • Migrations
      • Classic to Lightning Migration
      • Other Systems to Salesforce Migration
    • Integrations
  • HOW WE DO
    • Delivery Model
    • Our Works
  • BLOG

Developer Guide APEX – Data Types and Variables

Salesforce Blog | Salesforce Simple Tutorial > Salesforce Admin Tutorial > Developer Guide APEX – Data Types and Variables
  • January 5, 2023
  • Merfantz Blogger
  • 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


  • Previous Aura Components Vs Lightning Web Components
  • Next Top Benefits using Salesforce CDP with Merfantz
We denounce with righteous indignation in and dislike men who are so beguiled and to demo realized by the charms of pleasure moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound.

Discover More

Contact Info

  • 374 William S Canning Blvd, Fall River MA 2721, USA
  • (+880)155-69569
  • [email protected]
  • 10:00 - 17:00

Latest Posts

Salesforce Marketing Cloud Will Fuel Your B2B Marketing Engine. January 30, 2023
Overview of DML operations in Apex January 24, 2023
Benefits of Integrating Salesforce and Marketing Automation for Business Growth January 20, 2023

2023 All Rights Reserved