Skip to content

Instantly share code, notes, and snippets.

View Nahumancer's full-sized avatar
🏠
Working from home

Nahuel Bergamo Nahumancer

🏠
Working from home
View GitHub Profile
@Nahumancer
Nahumancer / Capacitacion.md
Last active January 1, 2021 15:58
Capacitacion guiada Salesforce

Bienvenides a la capacitacion guiada en Salesforce! Aca les dejo los detalles del formato de esta capacitacion.

  • No hay clases en dias/horarios fijos
  • La curricula es una serie de modulos que pueden seguir en su propio tiempo, con el ritmo y velocidad que ustedes quieran
  • En todo momento de dispone de un discord para consultas -> https://discord.gg/WekTNJmxmS
  • En ciertos dias/horarios, voy a avisar que prendo una videollamada para atender consultas que requieran de compartir la pantalla y mayor atencion que un chat.

Lo primero es hacerse una cuenta y comenzar con el primer trail "Get Started with Trailhead" que explica como funciona la plataforma que usamos para aprender Comiencen en este link: - https://trailhead.salesforce.com/en/users/nahuelbergamo/trailmixes/capacitacion-salesforce

@Nahumancer
Nahumancer / DeleteApexLogsSFDX
Created August 31, 2020 17:52
Delete Apex Logs using SFDX
sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" -r "csv" > out.csv
sfdx force:data:bulk:delete -s ApexLog -f out.csv
@Nahumancer
Nahumancer / OrgUtilities.cls
Last active February 9, 2020 16:57
Salesforce Apex: Check if the current ORG is a Sandbox. / Required: Summer '14 (version 31.0)
// To be used like:
// if (OrgUtilities.runningInASandbox()) { etc.. }
public class OrgUtilities {
public static Boolean runningInASandbox {
get {
if (runningInASandbox == null) {
runningInASandbox = [SELECT IsSandbox FROM Organization LIMIT 1].IsSandbox;
}
return runningInASandbox;
@Nahumancer
Nahumancer / PicklistValues
Last active April 21, 2019 20:33
Get picklist valid values.
public static String[] getValidPicklistValues(String object_name, String field_name) {
String[] values = new String[]{};
String[] types = new String[]{object_name};
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(types);
for(Schema.DescribeSobjectResult res : results) {
for (Schema.PicklistEntry entry : res.fields.getMap().get(field_name).getDescribe().getPicklistValues()) {
if (entry.isActive()) {values.add(entry.getValue());}
}
}
return values;
@Nahumancer
Nahumancer / TestUser.cls
Created April 19, 2019 19:37
Test User creation
public static void generateTestUser(String randomUserName){
System.runAs ( new User(Id = UserInfo.getUserId()) ) {
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
User auxTestUser = new User();
auxTestUser.Alias = 'standt';
auxTestUser.Email = 'testemail@org.com';
auxTestUser.EmailEncodingKey = 'UTF-8';
auxTestUser.LastName = 'Test';
auxTestUser.LanguageLocaleKey = 'en_US';
auxTestUser.LocaleSidKey = 'en_US';
@Nahumancer
Nahumancer / TestCoverageCleanupQuery
Created April 10, 2019 20:42
Test Coverage Cleanup Query (Use Tooling API in Dev Console)
SELECT Id, ApexClassOrTriggerId, ApexClassOrTrigger.Name,
NumLinesCovered, NumLinesUncovered
FROM ApexCodeCoverageAggregate
@Nahumancer
Nahumancer / HL_FieldDescribeUtil.cls
Created August 10, 2018 03:56
Class by Benj Kamn. Stored here for personal reference/quick access.
/*
* 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.
*
@Nahumancer
Nahumancer / PriceBookTest.cls
Created September 4, 2017 20:46
Utility method to create Product/Pricebook/PricebookEntry combo for tests. Taken from https://releasenotes.docs.salesforce.com/en-us/summer14/release-notes/rn_apex_price_books_in_tests.htm
@isTest
public class PriceBookTest {
// Utility method that can be called by Apex tests to create price book entries.
static testmethod void addPricebookEntries() {
// First, set up test price book entries.
// Insert a test product.
Product2 prod = new Product2(Name = 'Laptop X200',
Family = 'Hardware');
insert prod;