Skip to content

Instantly share code, notes, and snippets.

/**
* Created by sonal on 2024-01-01.
*/
/**
* Validate unique constraints on Salesforce objects. It accepts a list of records and checks if there are
* any duplicate records based on the fields specified in the constructor.
* The SObjectType represents the type of Salesforce object that the class will work with, and the list of
* fields represents the fields that should be unique.
*/
@iamsonal
iamsonal / Subscription Products
Created April 16, 2023 17:25
Subscription Products
Pricing
There are two pricing options here. Fixed Price or Percent of Total.
Fixed Price subscriptions are products that have just that, a fixed price. This fixed price can either be a one specific price for the product -or- be obtained from a table of prices or “rate card” as some folks call it. The rate card is a set of prices for a given product, divided up by a set of tiering criteria such as quantity range.
Percent of Total subscriptions are products where the price is calculated based on a specific percentage of the total cost of the quote. Common products that are percent of total are warranty products and maintenance products.
Perhaps you have a warranty covering products purchased and the cost of which is 10% of the products that are being purchased.
Or maybe you are a SaaS company and sell perpetual licenses to your software. You might have a yearly maintenance fee that is priced to be 20% of the perpetual license purchase price.
@wire(getRecordCreateDefaults, {objectApiName: '$objectApiName', recordTypeId : '$recordTypeId'})
recordCreateDefaults({ data, error }) {
if (data) {
const recordInput = generateRecordInputForCreate(
data.record,
data.objectInfos[this.objectApiName]
);
console.log(recordInput);
this.recordUi = data.layout;
this.loading = false;
public static Boolean isChanged(SObject aObj, Schema.SObjectField aField) {
return Trigger.isInsert ||
aObj.get(String.valueOf(aField)) != Trigger.oldMap.get(aObj.Id).get(String.valueOf(aField));
}
public static void sendEmail(Map<Id, Order> orderMap) {
List<ContentDocumentLink> contentDocumentLinks = [
SELECT Id, ContentDocumentId, LinkedEntityId
FROM ContentDocumentLink
WHERE LinkedEntityId IN :orderMap.keySet()
];
Map<Id, List<ContentDocumentLink>> contentDocumentLinksByOrderId = new Map<Id, List<ContentDocumentLink>>();
Set<Id> contentDocumentIds = new Set<Id>();
@iamsonal
iamsonal / ClassA.cls
Created July 4, 2022 22:02
Update Picklist in Salesforce using Metadata API
MetadataApiService.MetadataPort service = createService();
MetadataApiService.CustomField customField = (MetadataApiService.CustomField) service.readMetadata('CustomField', new String[]{
'Account.Demo__c'
}).getRecords()[0];
MetadataApiService.GlobalValueSet globalValueSet = (MetadataApiService.GlobalValueSet) service.readMetadata('GlobalValueSet',
new List<String>{
customField.valueSet.valueSetName
}).getRecords()[0];
#!/usr/bin/env python3
import os
import sys
import re
from pathlib import Path
def listfiles(folder):
for root, folders, files in os.walk(folder):
for filename in folders + files:
#############################################################################
## SETUP DEMO ##
#############################################################################
cd /Users/first.last/Documents/workspace/cli-demo-repo
CONSUMER_KEY="xxxx"
USERNAME="xxxx"
INSTANCE_URL="https://login.salesforce.com/"
KEY="../cli-demo/server.key"
rm -rf "/Users/first.last/Documents/workspace/cli-demo-repo/output"
@iamsonal
iamsonal / Mac Setup ZSH.txt
Last active June 13, 2021 22:27
Mac Setup ZSH
sudo spctl --master-disable
https://github.com/ohmyzsh/ohmyzsh
How to Install Zsh/ zsh-autosuggestions/ oh-my-zsh in Linux
https://varunmanik1.medium.com/how-to-install-zsh-zsh-autosuggestions-oh-my-zsh-in-linux-65fa01cc038d
@iamsonal
iamsonal / Git Tips.txt
Last active March 20, 2024 14:26
Git Tips
URL:https://sethrobertson.github.io/GitFixUm/fixup.html
Checkout evHeroHeader.html file from "feature/events/events-record-list" branch to your working branch:
git checkout feature/events/events-record-list force-app/events/main/default/lwc/evHeroHeader/evHeroHeader.html
Pull all the files from master branch to your working branch:
git pull origin master
Reset a branch