MIN() Function in Salesforce | Syntax, Examples, & Use Cases

Calculate minimum value using Salesforce Classic

The MIN() function in Salesforce returns the smallest of two or more numbers: MIN(Discount__c, 0.25) caps a discount at 25%. It only accepts numbers, so MIN(StartDate, CustomerSignedDate) fails, but you can still find the earliest of several dates with a simple workaround that I tested below. In this tutorial, you’ll find the syntax, practical number … Read more >>>

MID() Function in Salesforce: Get Substring in Formula Fields

Salesforce Classic Example MID Function

The MID() function in Salesforce returns a set number of characters from the middle of a text value, starting at a position you choose: MID(“Salesforce”, 6, 5) returns “force”. Combined with FIND(), it extracts text between two markers, such as the domain of an email address or the code after a “#”. Most MID tutorials … Read more >>>

How to Use Record Choice Set in Salesforce Screen Flow

Flow Resource Record Choice Set in Salesforce

A record choice set in a Salesforce screen flow turns records into the options of a Picklist, Radio Buttons or Checkbox Group component. The flow queries the records you filter for, such as active Accounts, shows a field like Name as the label, and stores the field you choose, usually the record ID, as the … Read more >>>

How to Query Multi-Currency Fields in Salesforce SOQL?

Query Multi-Currency Fields in Salesforce SOQL

To query multi-currency fields in Salesforce SOQL, wrap the currency field in convertCurrency() to get it in the user’s currency, use FORMAT() to show it with the right symbol, and filter with an ISO value such as Amount > USD5000. In Apex, give convertCurrency() an alias and read it with get(‘alias’). Most guides stop at … Read more >>>

Salesforce DATEVALUE Function: Syntax, Examples, and Uses

Create a Salesforce DATEVALUE Formula Field

The DATEVALUE() function in Salesforce converts a Date/Time value, or text in YYYY-MM-DD format, into a Date. DATEVALUE(CreatedDate) returns just the day a record was created, in the viewing user’s time zone, so you can compare it with TODAY(), count days, or group records by day. The time-zone part is where most formulas go wrong, … Read more >>>

Long Text Area Salesforce

Salesforce create text area long field type

A Long Text Area in Salesforce (field type “Text Area (Long)”) holds up to 131,072 characters of plain text on multiple lines, with a default of 32,768 when you create it. Each object can use 1,638,400 characters in total across all its long and rich text area fields. I confirmed every limit on this page … Read more >>>

How to Get Current User Info Using Apex in Salesforce

How to Get Current User Info Using Apex in Salesforce

To get current user info using Apex in Salesforce, call the static methods of the built-in UserInfo class: UserInfo.getUserId() returns the user’s ID, UserInfo.getUserEmail() the email, UserInfo.getProfileId() the profile, and so on. They need no SOQL query, so they don’t count against query limits. Most tutorials list these methods without showing what they actually return. … Read more >>>

Salesforce REGEX Function

REGEX Function in Salesforce Classic Example

The REGEX function in Salesforce checks whether a text value matches a pattern and returns TRUE or FALSE. It is the standard way to enforce formats such as ZIP codes, phone numbers, product codes or IDs in validation rules, for example NOT(REGEX(BillingPostalCode, “\\d{5}”)) blocks any postal code that isn’t exactly five digits. Most REGEX tutorials … Read more >>>

SOQL Query on Group and GroupMember in Salesforce

Query inactive users from groups in Salesforce

To query groups in Salesforce, use two objects: Group, which holds every public group, queue and role group, and GroupMember, which holds one row for each member of a group. A SOQL query on Group and GroupMember lets you list public groups and queues, see who is in them, and find every group a user … Read more >>>