Skip to content

Instantly share code, notes, and snippets.

View scolladon's full-sized avatar

Sebastien scolladon

View GitHub Profile
@scolladon
scolladon / ApexID15to18.cls
Last active September 23, 2016 18:40
Apex ID 15 to 18
public static string generate18CharId(final string id){
final String abecedair = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345';
if (String.isBlank(id) || (id.length() != 15 && id.length() != 18)) {
return null;
}
if (id.length() == 18) {
return id;
}
string suffix = '';
for (integer i = 0; i < 3; i++) {
@scolladon
scolladon / RecordTypeHandler.cls
Created May 16, 2016 16:20
Apex RecordType Handler
public with sharing class RecordTypeHandler {
// Build a local cache so that we don't request this multiple times
private static Map<Schema.SObjectType,Map<String,Id>> rtypesCache;
static {
rtypesCache = new Map<Schema.SObjectType,Map<String,Id>>();
}
// Returns a map of active, user-available RecordType IDs for a given SObjectType,
@scolladon
scolladon / UserRoleInserter.cls
Last active May 10, 2016 21:00
UserRoleInserter Salesforce
public class UserRoleInserter{
final private Map<String,String> roleNamePerParentRoleName;
public UserRoleInserter(){
this.roleNamePerParentRoleName = new Map<String,String>();
}
public void PutUserRoleHierarchy(final String aUserRole, final String aParentUserRole) {
this.roleNamePerParentRoleName.put(aUserRole,aParentUserRole);
}