How to Convert Decimal to Integer in Salesforce Apex

Convert decimal to integer in Salesforce apex

To convert a Decimal to an Integer in Salesforce Apex, use myDecimal.intValue(), which drops the decimal part (7.8 becomes 7). Integer.valueOf(myDecimal) compiles and gives the same result. To round instead of truncating, use myDecimal.round(System.RoundingMode.HALF_UP).intValue(). Several tutorials disagree on what Integer.valueOf() and type casting do with decimals, so I tested every method in the Developer Console … Read more >>>

How to Convert Integer Data Type to String in Salesforce Apex

How to Convert Integer Data Type to String in Salesforce Apex

While working on the Account object, I created the Account ID field using the Integer data type. However, the sales team wanted to store the account ID in alphanumeric form, which was not possible with the integer data type. I was required to convert the Integer data type to a string in Salesforce Apex. In … Read more >>>

Salesforce UNIXTIMESTAMP Function

UNIXTIMESTAMP Function in Salesforce Classic Example

The Salesforce UNIXTIMESTAMP function is used to retrieve the number of seconds that have elapsed since January 1, 1970 (Coordinated Universal Time or UTC). The UNIXTIMESTAMP function in Salesforce is a common topic of inquiry among learners who are aspiring Salesforce admins. Unfortunately, there is no online article that helps you understand. Don’t worry; I’m … Read more >>>

How to Apply Filter by Scope in Salesforce

salesforce report filter by scope

I was working as a system admin for an organization that uses Salesforce CRM. Recently, I was tasked with creating an account report that displays account records owned by specific users, along with their record criteria, in either report or list views within Salesforce. In Salesforce, we have the feature “Filter by Scope,” which allows … 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 >>>

Date Formula Functions in Salesforce

Date Formula Functions in Salesforce

A support lead asks for a list of opportunities with no activity for more than 30 days. The answer is a date formula in Salesforce that compares the Last Activity Date with TODAY(). Salesforce date formula functions are the built-in functions (TODAY, NOW, DATE, DATEVALUE, ADDMONTHS, WEEKDAY and others) that create, convert, compare and calculate … 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 Create Salesforce Report Group by Month and Year

Group a Report by Month in Salesforce Classic

The sales team generated many leads in a recent campaign conducted by our company, which works with Salesforce CRM. The campaign lasted a couple of months, and the sales team requested that the generated leads be grouped in a monthly format to analyze performance on a month-by-month basis throughout the campaign. As a solution, I … Read more >>>

How to Convert String to ID in Salesforce Apex

Convert and add list of string to set of ID in Salesforce Apex

While working on a Salesforce development project, I was debugging an Apex class that was supposed to update an account record based on its ID, but I kept encountering an “Invalid ID” error. Then, I tested and validated a string conversion to an ID type in the developer console to ensure the conversion logic worked … Read more >>>

HYPERLINK() Function in Salesforce [Syntax, Examples, & Use Cases]

Salesforce Lightning HYPERLINK Function

While working as a Salesforce Admin, I received a requirement from the client who sells home automation products. They wanted their support team to quickly access the installation video for every product that a customer purchases. For example, when a customer buys a product like Wi-Fi or a camera, the support team should see a … Read more >>>