Skip to content

Instantly share code, notes, and snippets.

View rahulmalhotra's full-sized avatar
😃
Working on something amazing...!!

Rahul Malhotra rahulmalhotra

😃
Working on something amazing...!!
View GitHub Profile
@rahulmalhotra
rahulmalhotra / sfdcstopapps.json
Created December 7, 2024 05:24
SFDC Stop Apps - Used in HTTPCalloutFramework
{"author":"Rahul Malhotra","apps":[{"id":"1","title":"HTTPCalloutFramework","url":"https://github.com/rahulmalhotra/HTTPCalloutFramework"},{"id":"2","title":"SFDX Deploy Tool","url":"https://github.com/rahulmalhotra/SFDX-Deploy-Tool"},{"id":"3","title":"Platform Event Toast - LWC","url":"https://github.com/rahulmalhotra/Platform-Event-Toast-LWC"}]}
@rahulmalhotra
rahulmalhotra / sfdcstopsessions.json
Created December 7, 2024 05:24
SFDC Stop Sessions - Used in HTTPCalloutFramework
{"author":"Rahul Malhotra","sessions":[{"id":"1","title":"Develop Lightning Components faster using Lightning Data Service","url":"https://www.sfdcstop.com/2017/12/develop-lightning-components-faster.html"},{"id":"2","title":"Agentforce for Developers","url":"https://trailblazercommunitygroups.com/events/details/salesforce-salesforce-developer-group-new-delhi-india-presents-delhincrohana-deep-dive-into-einstein-for-developers-amp-einstein-copilot/"}]}
@rahulmalhotra
rahulmalhotra / sfdcstopblogs.json
Last active December 7, 2024 02:10
SFDC Stop Blogs - Used in HTTPCalloutFramework
{"author":"Rahul Malhotra","blogs":[{"id":"1","title":"Building Blocks of Apex: Variables & Data Types Explained Simply - Salesforce Apex Tutorial Part 2 to 7 | Code Snippet","url":"https://www.sfdcstop.com/2024/04/variables-and-data-types-salesforce.html"},{"id":"2","title":"Collections in Apex - Salesforce Apex Tutorial Part 8 to 13 | Code Snippet","url":"https://www.sfdcstop.com/2024/08/collections-in-apex-salesforce-apex.html"},{"id":"3","title":"Apex Constants and Enums - Salesforce Apex Tutorial Part 14 to 16 | Code Snippet","url":"https://www.sfdcstop.com/2024/09/apex-constants-and-enums-salesforce.html"},{"id":"4","title":"Expressions and Operators in Apex - Salesforce Apex Tutorial Part 17 to Part 24","url":"https://www.sfdcstop.com/2024/10/expressions-and-operators-in-apex.html"},{"id":"5","title":"Control Flow Statements in Apex | if else | switch case | loops - Salesforce Apex Tutorial Part 25 and Above","url":"https://www.sfdcstop.com/2024/12/control-flow-statements-in-apex-if-else.html"}]}
@rahulmalhotra
rahulmalhotra / batch-apex-mechanism-detail.cls
Created January 9, 2022 11:31
Code used in "How many batches will be executed? 20000 records & 250 batch size | Salesforce Batch Apex Interview" (https://youtu.be/LgHxpR_6Vrs)
-> 'Create a Batch Class to opt out contact records from email, call and fax whose Unsubscribe Date has passed'
20,000 records -> total
200 records
How many batches?
-> 20,000 / 200 -> 100 batches in total
@rahulmalhotra
rahulmalhotra / batch-apex.cls
Created December 22, 2021 17:15
Code used in "How to create a Batch Class in Salesforce Apex? | Batch Apex | Apex Tutorial Series by SFDC Stop" (https://youtu.be/1JyWuEQrHco)
/*
* Author:- Rahul Malhotra
* Description:- This batch class is used to update all contacts who have opted out of email, call and fax
* Created:- 18-12-2021
* Last Updated:- 18-12-2021
*/
public class UpdateContactsBatch implements Database.Batchable<sObject> {
// * Return a maximum of 50 million records
public Database.QueryLocator start(Database.BatchableContext batchableContext) {
@rahulmalhotra
rahulmalhotra / enable_first_checkbox_on_page.js
Last active December 12, 2021 04:59
This gist is used to enable first checkbox named "enable" on current page
let inputs = document.getElementsByTagName('input');
for(let input of inputs) {
if(input.type === 'checkbox' && input.name === 'enable') {
input.disabled = false;
break;
}
}
@rahulmalhotra
rahulmalhotra / sort-util.cls
Created December 9, 2021 18:41
Code used in "Sort a list of sObject records based on a field value | Salesforce Apex Tutorial Series by SFDC Stop" (https://youtu.be/4qyJfelUMjs)
-----------------------------------------------------------------------------------------
-> Sort a list of sObject records based on field value
-----------------------------------------------------------------------------------------
List<Account> accounts = new List<Account>();
accounts.add(new Account(
Name = 'Hooli',
NumberOfEmployees = 50,
AnnualRevenue = 10000
));
@rahulmalhotra
rahulmalhotra / enum.cls
Created December 7, 2021 16:12
Code used in "Enums in Apex | What is Enum and where do we use it? | Salesforce Apex Tutorial Series by SFDC Stop" tutorial on SFDC Stop (https://youtu.be/N3du8bRbYSs)
-------------
Enums in Apex
--------------
An enum is an abstract data type whose values consist of a finite set of identifiers.
Enums are typically used to define a set of possible values that don’t otherwise have a numerical order.
public enum Color { RED, BLUE, GREEN, ORANGE, PURPLE }
values()
@rahulmalhotra
rahulmalhotra / custom-comparator.cls
Created December 4, 2021 15:11
Code used in "Apex List Comparator | System.ListException: One or more of the items in this list is not Comparable" tutorial on SFDC Stop (https://youtu.be/Sf95Bl_zP2U)
---------------------------------------------------------------------------------------------------------------------------
Custom Comparator
---------------------------------------------------------------------------------------------------------------------------
List<Integer> numbers = new List<Integer>{ 5, 3, 2, 1, 4 };
System.debug('Initial list of Integers => ' + numbers);
System.debug('Sorting Integers....');
numbers.sort();
@rahulmalhotra
rahulmalhotra / solvingrealworldproblemusingmapapex.cls
Created November 25, 2021 15:11
Code used in "Write efficient code using Data Structures in Salesforce Apex | Reduce Time Complexity using Map" video on SFDC Stop (https://youtu.be/KJOt-QVNOds)
// * Link accounts with parent accounts
Update 10,000 accounts
-----------------------
// * Brute Force Approach - Very time consuming
List<Account> accounts = [SELECT Reference_ID__c, Parent_Reference_ID__c FROM Account];
List<Account> accountsToUpdate = new List<Account>();