Skip to content

Instantly share code, notes, and snippets.

@asmitakhare
asmitakhare / WeekOneHomework.apxc
Last active August 27, 2020 15:13
Week 1 Asmita Primitive Exercise
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'
@asmitakhare
asmitakhare / Week 1 Homework. Asmita. Apx
Last active August 17, 2020 17:22
Week 1 Asmita--Primitive and Assignment
public with sharing class Welcome {
//Welcome! I'm a comment and I'm here to tell you what this particular class file is for. The developer who created this class added
//me so that future developers, like yourself, would have a quick little introduction to what this class does.
//The two little slashes tell the compiler* that everything following on this line is a note
//for humans and not code that needs to be executed
// (* A compiler is the computer program that translates this code into executable computer instructions)
//But you know what? This set of comments is already several lines long and getting longer. I'm tired of typing two slashes every time
@asmitakhare
asmitakhare / Asmita WeekThreeHomework.apxc
Last active September 1, 2020 01:06
Asmita WeekThreeHomework.apxc
public with sharing class WeekThreeHomework{
public static void homeworkAssignmentMethod() {
//Read through the setup below and then complete the code following the prompts. When you're done, make sure to compile (save) your work
//Open Execute Anonymous in the Developer Console and execute your code by typing in: WeekThreeHomework.homeworkAssignmentMethod();
//Read through the debug statements to make sure you're done your work correctly.
//************************************************************************************************************
@asmitakhare
asmitakhare / Asmita WeekFourHomework.apxc
Created September 7, 2020 00:16
Asmita Week4Homework
public with sharing class WeekFourHomework {
//Let's practice calling different methods by writing our very own methods. You will write and save methods in the space below
//that call the existing methods you see already written here. Ready? Let's Go!
//Sample: Here is a public method that calls the getCitiesForExpansion below and prints the results to our debug log
public static void printOutCitiesForExpansionDemo() {
//The code on the left of the equals sign instantiates a list of Strings, the code on the right side calls our method and returns a list of cities
//the equals sign assigns the returned value, to the list we created
@asmitakhare
asmitakhare / Asmita WeekFiveHomework.apxc
Last active September 14, 2020 22:57
Asmita Week 5 Homework.apxc
public with sharing class WeekFiveHomework {
// Remember Sets & Maps?? We did a little practice with Lists in week 2, but we need to make sure we know how to use Sets & Maps as well!!
public static void setsReview(){
//Your assignment: Play with Sets!
// 1. Create a set of Strings and add at least 5 entries
Set<String> firstStringSet = new Set<String>();
@asmitakhare
asmitakhare / Asmita WeeksixHomework.apxc
Created September 21, 2020 18:18
Asmita Week 6 Homework.apxc
public with sharing class WeekSixHomework {
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 LIMIT 5];
System.debug('This should be 5: ' + topFiveAccounts.size());
@asmitakhare
asmitakhare / controller class
Created September 25, 2020 21:27
controller class
<apex:page Controller="CaseListClass">
<apex:pageBlock >
<apex:pageBlockTable value="{!cases}" var="c">
<apex:column value="{!c.Id}"/>
<apex:column value="{!c.Type}"/>
<apex:column value="{!c.CaseNumber}"/>
<apex:column value="{!c.Reason}"/>
</apex:pageBlockTable>
@asmitakhare
asmitakhare / AsmitaWeekSevenHomework.apxc
Created September 28, 2020 11:15
Asmita Week 7 home work
//We're calling this 'BadAccountTrigger' because this trigger has business logic directly coded in the trigger file. It's also using
//way more parameters (on line 7) than it actually uses in the trigger itself. Both of these are considered bad practice.
//Business logic coded directly in a trigger and having extra stuff in your code both make the code hard to read and hard to maintain.
//The 'GoodAccountTrigger' shows how to use a handler class with your trigger and is much simpler to read.
//For more information on trigger syntax: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_syntax.htm
trigger AccountTriggerBad on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
//Each section of code below handles a different event & timing combination. For now, we are demonstrating a trigger that has all of the logic right here.
//Later on we'll be looking at other ways of handling Trigger events u
@asmitakhare
asmitakhare / Asmita WeekEightHomework.apxc
Last active October 6, 2020 18:06
Asmita WeekEightHomework.apxc
public with sharing class WeekEightHomework {
//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
@asmitakhare
asmitakhare / StockItemHandler.Apxc Final project
Last active October 14, 2020 00:16
StockItemHandler.Apxc FinalProject.Asmita
/**
* A Utility class to process Stock Item records from the Stock Item Handler
*/
public with sharing class StockItemHandler {
/**
* Class constructor.
*/
public StockItemHandler() {