Understanding Data Types in Salesforce

Data types in Salesforce define the kind of data that can be stored in a field. They ensure that the data entered is consistent, valid, and usable for various operations like reporting, automation, and integrations. Salesforce primarily categorizes data into five main types within its API:

  1. ID
  2. String
  3. Boolean
  4. Double
  5. Varies by Type

Detailed Breakdown with Examples:

  1. ID
    • What It Is: A unique identifier automatically assigned to each record in Salesforce.
    • Example: Every record, whether it’s an Account, Contact, or Custom Object, has a unique 18-character ID like 0011x000003DGbRAAW. This ensures that each record can be distinctly referenced, especially when creating relationships between objects.
  2. String
    • What It Is: Represents text-based data.
    • Example: Fields such as FirstName, LastName, or Email use the String data type. For instance, a Contact Name field might contain “Jane Smith.”
  3. Boolean
    • What It Is: Stores true or false values.
    • Example: A Subscribed to Newsletter checkbox field allows users to indicate whether a contact is subscribed (True) or not (False).
  4. Double
    • What It Is: Handles numerical values that include decimal points.
    • Example: A Discount Percentage field might store values like 15.5 to represent a 15.5% discount.
  5. Varies by Type
    • What It Is: Used for fields like formulas where the resulting data type depends on the formula’s logic.
    • Example: A Total Price formula field might calculate a value based on other fields and could return a currency type if the formula multiplies quantity by unit price.

We can group different field types depending on the Data types.

IDLook up relationship, master-detail relationship
StringAuto number, email, phone, multi select pick list, text, text area, long text area, rich text area, data category group reference and URL
BooleanCheck box
DoubleCurrency, Formula, number, percent and roll-up summary.
Varies by typeFormula Field

Different Field Types

Auto number : when auto number data types is selected a system-generated sequence number that uses a certain display format that we define. Auto generated number will be increment for every record we create.

  • Example: An Order Number field might start at 1001 and increment by 1 for each new order (e.g., 1001, 1002, 1003).

Formula  : When Formula data type is selected we are able to derive different Formula expressions that derives values. The formula field is updated every time when there is a change in source field. It is a read-only field type.

  • Example: A Total Cost formula field could calculate the sum of Unit Price multiplied by Quantity (Unit Price * Quantity).

Roll-up Summary : Roll-up Summary is also a read-only field type. By using this Roll-up Summary data types we are able to make some mathematical calculations like Sum, Minimum, Maximum values of a afield in a related list or the record count of all records listed in a related list.

  • Example: On an Account record, a Total Opportunities field might count all related Opportunity records.

Lookup Relationship : This type of Data type links two objects. we can link on object to another object by Lookup relationship. This data type field allows user to select a value from popup list.

  • A Contact record might have a lookup to an Account, enabling the association of a contact with a specific company.

Master-detail relationship : Master-detail relationship also links two objects but it creates a special type of parent-child relationship between the two objects.

  • An Invoice (child) linked to a Customer (parent). Deleting the Customer would also delete all related Invoices.

Checkbox : If a user wants boolean function like true or false this Checkbox data types is used.

  • Example: An Active Customer checkbox indicates whether a customer is currently active.

Currency : Currency field type allows user to enter INR or any other country currency values in the record.

  • Example: A Sales Amount field allows entry of values like $1,500.00.

Date : Allows user to enter date or we can select the date from popup calendar.

  • Example: A Contract Start Date field lets users select a date from a calendar.

Date/ time  : Date and Date/Time field types are different from each other. In Date/Time the user can select date from popup calendar and also current time is entered in the Date/Time field.

  • Example: An Event Start field records when an event begins, including the exact time.

Email : Allows users to enter Email address.

  • Example: A Contact Email field might contain jane.doe@example.com.

Geolocation : Allows users to enter altitude and longitude values.

  • Example: A Store Location field could map the exact position of a retail outlet.

Number : Allows users to enter numbers.

  • An Employee Count field might hold values like 50.

Percent : Automatically percentage sign is added .

  • Example: A Completion Rate field where users can enter 75%.

Phone : Allows users to enter Phone Number.

  • Example: A Customer Support Number field might display (123) 456-7890.

Picklist : Allows users to select only on list from a group of lists that we defined. Picking one among many.

  • Example: A Customer Status field with options like “New,” “Active,” “Inactive.”

Text : Allows users to enter combination of both letters and numbers.

  • Example: A Product Code field might contain PRD-001A.

Text Area : Allows users to enter up to 255 characters of letters and numbers.

  • Example: A Short Description field for a product.

Text area (Long) : Allows users to enter up to 32,768 characters on separate lines.

  • Example: A Detailed Product Description field allows comprehensive information about a product.

Text Area (Rich) : Allows users to enter formatted text, add images and links up to 32,768 characters on separate lines.

  • Example: A Marketing Description field where users can add formatted text and images.

Text(Encrypted) : Allows users to enter any combination of letters an numbers and store them in encrypted format.

  • Example: A Password field that encrypts the entered password to protect sensitive information.

URL : Allows users to enter a valid website address.

Picklist (multi-select) : Allows users to select many from a group of list that we defined

  • Example: A Company Website field might contain https://www.company.com.