Skip to content

Instantly share code, notes, and snippets.

View oakye's full-sized avatar

Liz Kao oakye

  • San Francisco, CA
View GitHub Profile
@oakye
oakye / RAD-Final-Project-DML2.cls
Created October 3, 2020 23:57
Salesforce Apex code to quickly create records into a custom object.
// 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)),
@oakye
oakye / RAD-Final-Project-StockItems-DML.cls
Created October 3, 2020 23:55
Salesforce Apex concept training. This quickly adds records into a custom object.
// 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)),
@oakye
oakye / CreateTwoContacts.apxt
Created September 22, 2020 21:58
Week 4 homework from the Salesforce Developer Curriculum by David Liu (bit.ly/go-apex)
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
@oakye
oakye / CreateAccountFromLead.apxt
Created September 7, 2020 23:39
Week2 homework, extra credit, & test classes from David Liu's Salesforce Development Curriculum (bit.ly/go-apex)
// 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>();