Skip to content

Instantly share code, notes, and snippets.

View RokhaO's full-sized avatar

Rokha Ou RokhaO

View GitHub Profile
@rsoesemann
rsoesemann / HttpMock.cls
Last active June 1, 2021 13:20
apex-http-mock
@IsTest
public class HttpMock implements HttpCalloutMock {
private static final String ANY_URL = null;
private Map<String, Map<String, Object>> responses = new Map<String, Map<String, Object>>();
// PUBLIC
@abd3
abd3 / Comprehensive Trigger Template
Created July 28, 2019 19:41
"Comprehensive Trigger Template" by Mike Leach
This text and the code below, originally came from a blog post from Mike Leach. That blog has subsequently been taken offline, but the contents are shared here for reference.
From Mike Leach:
====
I decided to create a more fluent Trigger template to address the following challenges and prevent me from repeatedly making the same mistakes:
* Bulkification best practices not provisioned by the Trigger creation wizard
* Use of the 7 boolean context variables in code (isInsert, isBefore, etc...) greatly impairs readability and long-term maintainability
* Trigger.old and Trigger.new collections are not available in certain contexts
* Asynchronous trigger support not natively built-in
@msrivastav13
msrivastav13 / generatepkgXML.sh
Created October 12, 2018 04:18
Generates package.xml from the Unmanaged container/Managed Package or Changesets
#!/bin/bash
if [ $# -lt 1 ]
then
echo Usage: generatepkgXML.sh orgalias packageName
exit
fi
## Retrieve the PackageXML from Unmanaged Container
@brianmfear
brianmfear / AccountData.cls
Last active January 29, 2020 15:41
lightning:tree with account hierarchy recursion example
public class AccountData {
@AuraEnabled public static Account[] getRecords() {
return [SELECT Name, ParentId, (SELECT Name FROM Contacts) FROM Account];
}
}
@sjurgis
sjurgis / lts-unit-test.MD
Created April 18, 2018 07:20
How to do actual unit testing in Lightning Testing Service

Expose helper via an public aura:method function in your abstract component's testHelperController.js:

getHelper: function(component, event, helper) {
 if ( $T ) {
  return helper;
 } else {
  throw new Error('API is only supported in test context');
 }
}
@toanshulverma
toanshulverma / DataDisplayController.cls
Last active May 16, 2024 20:18
Sample Code to Generate PDF from Lightning components with in-memory data
public class DataDisplayController {
public String PDFData {get; set;}
public DataDisplayController(){
PDFData = '';
}
public PageReference downloadPDF(){
System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');
@xixiaofinland
xixiaofinland / sfdx-cheatsheet.sh
Last active March 28, 2024 18:54
Salesforce SFDX Cheat Sheet
# Proudly supplied by Salesforce Way Site: https://salesforceway.com
# This cheatsheet contains the most often used SFDX commands for beginners to get a jumpstart.
# Hint. it is highly recommended to use `-h` to check the usage of any SFDX commands and corresponding parameters.
# For instance, use `sfdx force:auth:web:login -h` to checke what `-d` `-a` parameters do
# List down all supported dx commands:
sfdx force:doc:commands:list
# Check current DebHub and Scratch Org status
sfdx force:org:list
sfdx force:doc:commands:list
=== Commands
force:alias:list # list username aliases for sfdx
force:alias:set # set username aliases for sfdx
force:apex:class:create # create an apex class
force:apex:execute # execute anonymous apex code
force:apex:log:get # fetch a debug log
force:apex:log:list # list debug logs
force:apex:test:report # display test results
force:apex:test:run # invoke apex tests
//--------------------------------------------------------------
//Author- Sunil Kumar (sunil02kumar@gmail.com)
//Date - 15 Jan, 2017
//Purpose - Controller for ComponentHierarchy to generate Data for record Hierarchy
//-----------------------------------------------------------
public class hierarchyComponentController {
public string recordid{get;set;}
public String objectAPIName{get;set;}
public String parentFieldAPIName{get;set;}
@g0t4
g0t4 / links.md
Last active May 10, 2021 08:14
Starting Point Files for Jenkins2 Getting Started course