Arithmetic with exponents used to be an unsuspecting hassle. Legacy languages or even older versions of more current languages required standalone functions or even imported methods to raise a number to a given power.
For example, in C++ we’ll need to include the
math.h library and use the
pow() function. Similarly, older version of PHP use the
Granted many older languages have since implemented improvements for exponentiation, Python has been silky smooth since the beginning.
Raising a number to an exponent in Python…
Unless learning and using Salesforce is your sole full-time job then you’re most likely in “do now, learn later” mode. Whether you’re a sales, marketing, or customer success team lead or an army of one trying to keep your business organized, you’re short on time and care about the results more than the process.
If there was one thing I could hit the pause button on, making you stop and learn first it’d be bulkification. This is for three reasons: (1) it’s easy to learn, (2) it’s easy to implement, (3) it’s a nightmare to unlearn and undo if overlooked.
The Date Class in Apex has some really nifty methods such as
daysBetween()— methods you didn’t know you needed, but you’re glad when you eventually do. Unfortunately, the quality of life methods exclude one that returns the name of the month. The most we have at our disposal is the numeric month value, but that’s not always sufficient.
In this article, we’ll discuss two strategies to lookup the name of a month from a Date Class instance. Each technique has their own pros and cons, so it’s up to you to pick the one you prefer.
The number of contacts per account is one of the first things anybody new to setting up Salesforce is interested in tracking. Unfortunately, a simple roll-up summary is not possible because the Contact sObject is a standard object.
Being unable to solve this requirement with a simple field, we need to use some of the Developer tools in Salesforce to auto-magically maintain this relationship between Account and Contacts.
In this tutorial we’ll use an Apex Trigger as the primary mechanism for tracking the number of contacts. …
Salesforce is fantastic for structuring data…a lot of data. You’ve taken the time to create a library of sObjects, broken apart all the data, but what happens when you want to do a search across multiple sObjects?
This is where Salesforce Object Search Language (SOSL) comes into play.
SOSL is perfect for querying names, emails, and other text-based data across a specified list of sObjects. Do you want to look into all the leads and opportunities that involve a specific email address? SOSL is your best friend.
We’re going to define the different parts of a SOSL query and go…
SOQL — Salesforce Object Query Language — is a mechanism for retrieving object data that resembles SQL. While SQL includes operations such as INSERT, ALTER, and DELETE, SOQL is confined to retrieving data…effectively SELECT statements only.
While this may seem confining, the reality is that SOQL has many quality-of-life improvements for working with Salesforce objects (sObjects). One of these perks is the way in which related parent and child data can be automatically retrieved without using JOIN statements.
In this article, we’ll go over two examples: how to include parent object data in a SOQL query and how to include…
Apex — the Salesforce programming language that is similar to and based on Java — includes both primitive and complex data types. A data type defines the type of value(s) that can be stored in a given structure since Apex is a strongly-typed language.
Primitive types — such as String, Integer, and Decimal — hold a single value. Conversely, Collections are Apex data types that may hold multiple values in a single identifier.
In this article, we’ll introduce the three types of Collections, when to use each, and provide example code to get you started.
Lists are an ordered collection…
Integer division is an arithmetic operation where division is performed, but the remainder is discarded leaving us with just an integer.
In other programming languages, the combination of division plus something akin to a “floor” function is used to achieve similar results.
quotient = 8 / 3;
whole_number = Math.floor(quotient);console.log(whole_number); // prints 2
Having to round-down a normal division operation may not be particularly difficult, but it can be annoying and inconvenient. Fortunately, Python has us covered with the integer division operator.
Starting in version 3.10, one of my last grievances with Python — relative to other languages — is being addressed: the beloved switch statement.
In this article, we’ll introduce what switch statements are and how they are implemented in Python. Enjoy the tutorial and look forward to some refactoring!
For the uninitiated, a switch statement is a programming decision structure where one of multiple branches is executed…
In this article we’ll cover two separate algorithms to accomplish this and wrap up the guide with a recommendation for generalizing the strategy for easy repeated use.
Before we begin, here’s the data set we’ll be using. …