Skip to content

Instantly share code, notes, and snippets.

@forcethesales
forcethesales / Approval Comments Grid Component
Last active June 27, 2017 16:54
Approval Process Comments Grid in VF Email
<apex:component controller="ApprovalRequestCommentsController" access="global">
<apex:attribute name="relatedToId" assignTo="{!targetObjectId}" type="String" description="ID of the record whose last approval comments to retrieve"/>
<table cellpadding="5" style="border-collapse: collapse " width="800" border="1">
<tr>
<td style="background-color: #0099CC; color: #FFFFFF" width="300">
<b>Date</b>
@forcethesales
forcethesales / WeekOneHomework
Created February 19, 2018 22:44
WeekOneHomework RAD women #crazytownbananapants
public with sharing class WeekOneHomework {
public static void introToPrimitives() {
//Primitives are the simplest elements in a programming language
/* A selection of primitives in Apex:
Integer: A number that does not have a decimal point, like 1 or 789 or -34
Decimal: A number that includes a decimal point like 1.34 or 456.78907654
String: Any set of characters surrounded by single quotes, like 'Apple' or 'I Love Strings' or '2 Legit 2 Quit'
@forcethesales
forcethesales / WeekOneHomework Part 2
Created February 19, 2018 22:51
RAD Women code homework, week 1, part 2.
public with sharing class CommentingOnCodeExercise {
//Your Assignment is to add comments describing what is being done in the methods below.
//Call out the concepts you learned in your readings and in class.
//declare a method called cartValues
public static void cartValues() {
//declare an integer and assign it a value
Integer minimumCartValue = 50;
@forcethesales
forcethesales / VF DonorDetail Page
Created March 15, 2018 15:13
Visualforce Page Donor Profile
//Accessed with Custom button on the Account object on the Household details page layout.
<apex:page standardController="Account" sidebar="false" lightningStylesheets="true" showHeader="false">
<h1 style="text-align:center;color:blue;">
The {!Account.Name}
</h1>
{!Account.BillingStreet}
{!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}
@forcethesales
forcethesales / WeekFiveHomework
Created March 26, 2018 20:21
RadWomen Week5Homework
public with sharing class WeekFiveHomework {
public static void soqlPractice() {
//1. Below is a SOQL query that should be returning the top 5 Accounts in our org based on Annual Revenue.
//Something's not quite right, can you fix the query?
List<Account> topFiveAccounts = [SELECT Id, Name, AnnualRevenue FROM Account WHERE AnnualRevenue != 0
ORDER BY AnnualRevenue DESC
LIMIT 5 ];
trigger AccountAddressTrigger on Account (before insert, before update) {
// Get the List of accounts
//List<Account> newAccts = new List<Account>(
//[SELECT Id,Match_Billing_Address__c,BillingPostalCode,ShippingPostalCode FROM Account WHERE Id IN :newAccts]);
for(Account alice : Trigger.New) {
if (alice.Match_Billing_Address__c == true) {
alice.ShippingPostalCode = alice.BillingPostalCode;
}
//Week 6 Homework: Properly bulkify this code:
List<Case> newCases = new List<Case>();
Id runningUserId = UserInfo.getUserId();
//Get the email address for the Account owner.
//move the SOQL query outside of the loop.
User u = [SELECT Id, Email FROM User WHERE Id = :runningUserId];
for (Account a : Trigger.new) {
Case c = new Case();
@forcethesales
forcethesales / gist:86c26dd1b2983db0a2fae0e9fb33ab65
Created April 3, 2018 23:28
Quote Before Trigger that gets Value from Opp and Writes it to the Quote
//written by Bobby Watson
public void OnBeforeInsert(Quote [] newQuotes){
Set<Id> opportunitiesToQuery = new Set<Id>();
// Loop over the new quotes and grab the opportunities they are associated to.
for (Quote q : newQuotes) {
opportunitiesToQuery.add(q.OpportunityId);
}
// Now we have a collection of opportunity IDs to query. So let's query for them.
@forcethesales
forcethesales / gist:8399b9a009ccd0a001b04064da1e39d0
Created April 11, 2018 17:02
RAD women week 7 homework. insert accounts and connected cases
public with sharing class WeekSevenHomework {
//Assignment: The following method is supposed to create the number of accounts specified in the argument that it takes.
//Each Account should be named 'Sample Account #sampleNumber' where sample number is the count. So if you created 2 Accounts
//one would be called 'Sample Account 1' and the other 'Sample Account 2'
//Also, when we're done inserting them, we will create a case for each one with a Status of 'New', Origin of 'New Account' and the
//desription and subject of your choice.
//This isn't working quite right. Can you use your debugging skills to fix it? I had to comment it out since it won't compile
@forcethesales
forcethesales / Deleter Class
Last active April 17, 2018 17:38
RAD Women Final Project Code
public class StockItemDeleter {
// declare a method, which accepts a list of stock items as a call this ListStockItems
public static void StockMethodDeleter (List <Stock_Item__c> ListStockItems) {
//before an item is deleted, check if the stock is at 0.
//if it is not at zero, create a case.
//The case should indicate the name of the item that was deleted,
//the id, and the number of stock that were on hand when it was deleted in the description.
//The rest of the case can be configured however you think best.
system.debug('ListSTockItems:' + listStockItems);