Skip to content

Instantly share code, notes, and snippets.

public class Loader {
public static Map<Id, Account> acountIdToRecordMap {
get {
if (acountIdToRecordMap == null) {
acountIdToRecordMap = new Map<Id, Account> ([Select Name from Account]);
}
return acountIdToRecordMap;
}
private set;
}
@dhoechst
dhoechst / OppTerrAssignDefaultLogicFilter.class
Last active January 30, 2023 21:13
Salesforce Opportunity Territory Assignment Logic
/*** Apex version of the default logic.
* If opportunity's assigned account is assigned to
* Case 1: 0 territories in active model
* then set territory2Id = null
* Case 2: 1 territory in active model
* then set territory2Id = account's territory2Id
* Case 3: 2 or more territories in active model
* then set territory2Id = account's territory2Id that is of highest priority.
* But if multiple territories have same highest priority, then set territory2Id = null
*/
@dhoechst
dhoechst / QuoteApprovalController.cls
Created November 18, 2021 17:50
Salesforce CPQ Submit Quote Page that prevents multiple submits
public with sharing class QuoteApprovalController {
private SBQQ__Quote__c sbQuote;
ApexPages.StandardController qtController;
public SBAA__Approval__c[] approvals {
get {
if (approvals == null) {
approvals = SBAA.ApprovalAPI.preview(
sbQuote.Id,
SBAA__Approval__c.Quote__c
);