Pad Number with Leading Zeros

1 Oct

Left pad a number with leading zeroes

Thanks to for the concept and code. Below is my take on the function.

URL Parameters within Apex and Visualforce

28 Sep

Get a URL parameter from a Visualforce page

Get a map of URL parameters from a Visualforce page

Get URL Parameters in a Visualforce page

This assumes the URL is looks like this, “”.

Put values into Visualforce page’s URL and load a new page

Method 1: write out the URL

Method 2: Put parameters into a PageReference

Put values into the current test page’s URL in a Test Class

Salesforce Help

$CurrentPage Documentation
Controller Navigation Methods
Visualforce Parameters

Apex Loops, The Simple Things

18 Sep

For loop over a map’s keys (KeySet)

For loop over a map’s values

For loop over a list

For loop over a set

Code Snipits for Converting Salesforce Collections

8 Sep

Convert a Map to a List of keys

Convert a Map Values to a List of values

Convert an sObject List to a Map – Example 1 – New map with the List passed into the map’s constructor

Use this method when the map’s key value is the object’s Id. Thanks to this post for explaining the concept: King Koo

Convert an sObject List to a Map – Example 2 – Loop and Add

Use this method when the map’s key must be a field that is not an object’s id. This is useful when you need to find an object with a name instead of an Id value.

Report on Field Changes in Salesforce

26 Nov

Tracking field history in Salesforce allows you to report on the original and new values of a field. This functionality can be very useful when determining who changed a field value and when it happened. This built-in change tracking has some limits:

  • Only the following standard objects allow field history tracking: Accounts, Cases, Contacts, Entitlements, Service contracts, Contract line items, Contracts, Leads, Opportunities, and Solutions
  • Only 20 fields may be tracked per object
  • Not all field types can be tracked

Continue reading