Skip to content

Instantly share code, notes, and snippets.


Benj boxfoot

  • Health Leads
  • Minnesota, USA
View GitHub Profile
boxfoot / common.js
Created Dec 23, 2014
use `gulp cleanProfiles` to remove all negative (false) permissions from Salesforce permission files.
View common.js
/* By Benj Kamm, */
// Look for the value of the first text node within the current node.
// Returns 'false' if not found, otherwise the value of the first text node in the subnode.
function getXMLNodeValue(el, key) {
var matches = el.getElementsByTagName(key);
if (!matches.length) {
return 'false';
return matches[0].childNodes[0].nodeValue;
boxfoot / getDependentPicklists.cls (2017 approach)
Last active May 15, 2020
Handle cases where one dependent option can be used for multiple controlling options
View getDependentPicklists.cls (2017 approach)
* Apex doesn't expose dependent picklist info directly, but it's possible to expose.
* Approach:
* * Schema.PicklistEntry doesn't expose validFor tokens, but they are there, and can be accessed by serializing to JSON
* (and then for convenience, deserializing back into an Apex POJO)
* * validFor tokens are converted from base64 representations (e.g. gAAA) to binary (100000000000000000000)
* each character corresponds to 6 bits, determined by normal base64 encoding rules.
* * The binary bits correspond to controlling values that are active - e.g. in the example above, this dependent option
* is available for the first controlling field only.
boxfoot / gist:2322443
Created Apr 6, 2012
Determine current fiscal year in Apex
View gist:2322443
/* (c) Benj Kamm 2012
* Determine current fiscal year in Apex -- add this method to a class that needs it.
* FiscalYearStartMonth - Integer 1-12 corresponds to starting month of FY
* UsesStartDateAsFiscalYearName - If false, FY Name is year of ending month; if true, name from beginning month.
private integer getCurrentFY() {
Organization orgInfo = [SELECT FiscalYearStartMonth, UsesStartDateAsFiscalYearName
FROM Organization
You can’t perform that action at this time.