• Articles
  • Tutorials
  • Interview Questions

Salesforce: Data Types, Field Types, and Components

Salesforce Apex Language is an extremely robust programming language. Therefore, salesforce developer must use specific attributes and values when setting any variables in it. Here you will get all of the details about data types, field types and components used within Salesforce that may help define any variables correctly.

Check out this YouTube video on Salesforce Tutorial:

Video Thumbnail

Different DataTypes in Salesforce

Apex in Salesforce assigns a data type to all variables and expressions, such as sObject, primitive, or enum. We use these data types as required depending on the condition.

  • Integer, Double, Long, Date, Datetime, String, ID, or Boolean are examples of primitives 
  • An sObject, such as an Account, Contact, or MyCustomObject c, is either general or particular.
  • A collection that includes the following items:
    • A list (or array) of primitives, sObjects, user-defined objects, Apex classes created objects, or collections 
    • a collection of primitives
    • A primitive-to-primitive map, sObject, or collection
  • An enumeration is a typed list of values 
  • Objects made from Apex classes defined by the user
  • Objects built with Apex classes provided by the system
  • Null (for the null constant)

There are different data types depending on the circumstances. Here are the five in API:

  • ID
  • String
  • Boolean
  • Double
  • Varies by type

become a salesforce expert

Variables in Salesforce

  • Declaring and initializing local variables with one line, similar to Java, is possible here.
  • If you declare a variable but fail to assign any value for it, its status will become null – in its simplest form, null signifies a lack of any assigned value for a variable specified with primitive type.
  • Variables can be declared at any point in a block and then take on the scope from there. Sub-blocks can’t change the name of a variable that has already been used in a parent block, although parallel blocks may.

Get 100% Hike!

Master Most in Demand Skills Now!

Different Salesforce Field Types

Every field within Salesforce has a defined data type. When these fields are created in Salesforce, you are prompted to choose their data type, such as String, TextArea, Number, PickList, etc. It’s important to understand that these fields expect data of a certain type.

Field Type Description
Address A compound data type that contains address field data
AnyType A polymorphic data type that returns a string, picklist, reference, Boolean, currency, int, double, percent, ID, date, dateTime, URL, or email data depending on the kind of field involved
Calculated A field that is defined by a formula
Combobox A Combobox, which includes a set of enumerated values and allows the user to specify a value, not on the list
Currency  Currency values
DataCategoryGroupReference Reference to a data category group or a category unique name
Email Email addresses
EncryptedString An encrypted text field that contains any combination of letters/numbers/symbols stored in an encrypted form; you can set up a maximum length of up to 175 characters; available in API versions 11.0 and later.
ID A primary key field for an object
JunctionIdList A string array of referenced ID values representing the many-to-many relationship of an underlying junction entity; you have to query and manipulate the string array to query and manipulate the underlying junction entities in a single API call.
Location A compound data type that contains latitude and longitude values for geolocation fields
Masterrecord When records are merged, the ID of the record that is saved (the other records are deleted).
Multipicklist A multi-select picklist includes a set of enumerated values from which multiple values can be selected
Percent Percentage values
Phone Phone numbers; values can include alphabetic characters; client applications are responsible for phone number formatting
Picklist Picklist includes a set of enumerated values from which one value can be selected
Reference Cross-references to a different object; analogous to a foreign key field in SQL
Textarea A string that is displayed as a multi-line text field
URL URL values; usually, client applications should display these as hyperlinks

Different Salesforce Field Types Depending on the Data Types and their Transformation Data Types.

We can group different field types together with data types. Some of the examples are listed below.

Data Type Field Types Transformation Data Types
ID Look up relational, master-detail relationship String
String Auto number, email, phone, multi-select picklist, text, text area, long text area, rich text area, data category group reference, and URL String
Boolean Checkbox Integer
Double Currency, formula, number, percent, and roll-up summary Decimal
Varies by type A type must be given when formula fields are added to the user interface. Currency, date, date/time, number, percent, or text are all API data types that correspond to this type. String

Salesforce Components

  • TAB menu: In this, all tabs are arranged in a row.
  • All TAB menu: In this, you can find all the tabs available on salesforce.com.
  • More TAB menu: In this, you can find more tabs available on salesforce.com.
  • User menu: This is available at the top with a username. By using this component of Salesforce, you can change your profile settings.
  • Sidebar menu: In this, there are different sections such as build, monitor, jobs, logs, etc.
  • Application menu: It allows shuffling between applications.
  • Search Menu: It helps search in Salesforce.

Course Schedule

Name Date Details
Salesforce Certification 14 Dec 2024(Sat-Sun) Weekend Batch View Details
21 Dec 2024(Sat-Sun) Weekend Batch
28 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Salesforce Certified Professional

Rahul is a seasoned Salesforce Certified administrator and app builder with 10+ years of experience in many Salesforce technologies, such as Salesforce CRM and business process automation. In his free time, he likes to write and read about the latest technologies.