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
// This is my submission of Week 2's extra credit from David Liu's | |
// Salesforce Development Curriculum (bit.ly/go-apex) | |
// | |
// Write a trigger that automatically creates an Account | |
// whenever a Lead is created. The Account must be named after the last name of the Lead. | |
trigger CreateAccountFromLead on Lead (after insert) { | |
// create a List that is initially empty | |
List<Account> newAcct = new List<Account>(); |
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 createTwoContacts on Account (after insert) { | |
// Homework from Week 4 of the Salesforce Developer Curriculum | |
// bit.ly/go-apex | |
// Write a trigger that creates two identical Contacts whenever an Account is created. | |
// Make sure both Contacts are associated with the Account. | |
// Use any values for the fields on the Contacts - just make sure to use variables when | |
// populating the fields of each Contact to make sure they are identical. | |
// create a List to contain the Contacts that are being created |
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
// Use this in Execute Anonymous to create 5 Stock Itme records | |
// where the inventory on hand is less than the minimum stock level | |
List<Stock_Item__c> itemList = new List<Stock_Item__c>(); | |
for (Integer i = 5; i < 10; i++) { | |
Stock_Item__c stockitem = new Stock_Item__c( | |
Description__c = 'An item of stock', | |
Item_Name__c = ('RAD Item ' + i), | |
List_Price__c = (14.99 + (i * 10)), |
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
// Use this in Execute Anonymous to create 5 Stock Item records | |
// where the inventory on hand is greater than the minimum stock level | |
List<Stock_Item__c> itemList = new List<Stock_Item__c>(); | |
for (Integer i = 0; i < 5; i++) { | |
Stock_Item__c stockitem = new Stock_Item__c( | |
Description__c = 'An item of stock', | |
Item_Name__c = ('RAD Item ' + i), | |
List_Price__c = (20.00 + (i * 10)), |