This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FROM https://eltoro.secure.force.com/DynamicApexToCheckCrudAndFls | |
public class demoDynamicApexMethods { | |
public void SObject_Information() { | |
Schema.DescribeSObjectResult drSObj = Schema.sObjectType.Account; | |
System.debug(drSObj.getChildRelationships()); | |
System.debug(drSObj.getRecordTypeInfos()); | |
System.debug(drSObj.getRecordTypeInfosByID()); | |
System.debug(drSObj.getRecordTypeInfosByName()); | |
System.debug(drSObj.isCreateable()); | |
System.debug(drSObj.isAccessible()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecipeHelper { | |
public static void addIngredient (String ingredientName, Integer measurementAmount, String measurementType, ID recipeId) { | |
//code | |
//Your code should create an Ingredient SObject in memory and insert it in the database. | |
//The ingredient should have the recipe id provided as its parent. | |
Ingredient__c ingred = new Ingredient__c(); | |
ingred.Name = ingredientName; | |
ingred.Calories__c = 44; | |
ingred.Measurement__c=measurementAmount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecipeHelper { | |
public static void addIngredient (String ingredientName, Integer measurementAmount, String measurementType, ID recipeId) { | |
//code | |
//Your code should create an Ingredient SObject in memory and insert it in the database. | |
//The ingredient should have the recipe id provided as its parent. | |
Ingredient__c ingred = new Ingredient__c(); | |
ingred.Name = ingredientName; | |
ingred.Calories__c = 44; | |
ingred.Measurement__c=measurementAmount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_scheduled | |
@isTest | |
private class RemindOppyOwnersTest { | |
// Dummy CRON expression: midnight on March 15. | |
// Because this is a test, job executes | |
// immediately after Test.stopTest(). | |
public static String CRON_EXP = '0 0 0 15 3 ? 2022'; | |
static testmethod void testScheduledJob() { | |
// Create some out of date Opportunity records |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class AccountProcessorTest { | |
@TestSetup | |
static void dataCreation(){ | |
//create accounts | |
List<Account> newAccts = new List <Account>(); | |
Account account1 = new Account(Name = 'Adam'); | |
newAccts.add(account1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class RecipeTriggerHandler_Test { | |
@TestSetup | |
static void dataCreation(){ | |
// create difficult recipe | |
Recipe__c rec = new Recipe__c(); | |
rec.Name = 'Test Recipe 3'; | |
rec.Active_Time__c = 2; | |
rec.Description__c = 'recipe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class myDataGenerationTests { | |
@TestSetup | |
static void loadTestDataFromStaticResource(){ | |
List<sObject> accounts = Test.loadData(Account.SObjectType, 'Mock_Data'); | |
} | |
@isTest static void testLoadAccountsFromStaticResource() { | |
List<Account> accts = [SELECT ID FROM Account]; | |
system.assert(accts.size() == 15, 'expected 16 accounts'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Trigger by Prasanna Cherlopalle | |
//comments and questions by Jessie Rymph start with JR. Other comments are from Prasanna.trigger RecipeTrigger2 on Recipe__c ( before insert, after insert, before update, after update, before delete, after delete) { | |
if (Trigger.isBefore) { | |
if (Trigger.isInsert) { | |
// Instantiate the Handler and set Trigger records | |
// JR: so this is making an instance of the handler specifically for this time it runs. | |
// JR: see SFDC99 Example https://www.sfdc99.com/2015/01/19/the-one-trigger-per-object-design-pattern/ | |
// JR: This is sending a list with Trigger.new | |
RecipeTriggerHandler2 handler = new RecipeTriggerHandler2(Trigger.new); | |
//calling the method from the handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecipeTriggerHandler { | |
//trigger variables | |
//JR: Are these variables empty until the constructors actually populate them with the maps/lists? | |
List<Recipe__c> newRecipes; | |
Public static void updateRecipes(List<recipe__c> listRecipes) { | |
//loop through the recipes that were just created or updated | |
For (Recipe__c recipe:listRecipes){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lead Trigger | |
trigger LeadTrigger on Lead (after insert, after update) { | |
if (Trigger.isInsert) { | |
LeadCreateTaskTriggerHandler.createTaskAfterInsert(Trigger.new); | |
} | |
} | |
//Lead Trigger Handler |