Skip to content

Instantly share code, notes, and snippets.

View surajp's full-sized avatar
😄
Focusing

Suraj Pillai surajp

😄
Focusing
View GitHub Profile
@surajp
surajp / settings.jsonc
Last active June 16, 2021 02:04
Basic VS Code Settings for Salesforce Development
{
"workbench.colorTheme": "Default Dark+",
"git.postCommitCommand": "sync",
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.autofetch": true,
"terminal.integrated.fontFamily": "Consolas",
//"prettier.prettierPath": "/home/coder/.npm/lib/node_modules/prettier",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
@surajp
surajp / CreateNamedCredsController.cls
Created May 28, 2021 04:26
Create Named Credentials in Salesforce via Apex
public with sharing class CreateNamedCredsController {
public static final String CLIENT_ID = '<clientid>';
public static final String CLIENT_SECRET = '<clientsecret>';
public static final String API_VERSION='v51.0';
public static final String TOKEN_ENDPOINT_URL = 'https://login.salesforce.com/services/oauth2/token';
public static final String AUTHORIZE_ENDPOINT_URL = 'https://login.salesforce.com/services/oauth2/authorize';
public static final String REDIRECT_URL = URL.getSalesforceBaseUrl().toExternalForm()+'/apex/AuthHandler';
public static final String NAMEDCRED_TOOLING_ENDPOINT_URL = URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/'+API_VERSION+'/tooling/sobjects/NamedCredential/';
public static final String AUTH_PROVIDER_NAME = 'SF_Auth';
@surajp
surajp / lwc.html
Last active February 17, 2021 22:52
<template for:each="{forecastRevenues}" for:item="period">
<tr key="{period.index}">
<td
data-label="{period}"
data-id="{period.Id}"
data-field="Forcast_Period_Start__c"
>
<div class="slds-truncate" title="{period.Forecast_Period_Start__c}">
<lightning-input
type="date"
@surajp
surajp / retrieveAllEmailTemplates.sh
Last active July 17, 2022 00:43
One-liner to retrieve all Email Templates from an org into metadata folders
#!/usr/bin/env bash
set -euo pipefail
orgname="${1:-default}"
foldername="$2"
if [[ $foldername != "" ]]; then
query="Select Folder.DeveloperName,DeveloperName from EmailTemplate where Folder.DeveloperName='$foldername'"
else
query="Select Folder.DeveloperName,DeveloperName from EmailTemplate"
fi
# echo $orgname $query
@surajp
surajp / sf_standard_objects.txt
Created January 28, 2021 00:14
SF Standard Object Names
AIInsightAction
AIInsightFeedback
AIInsightReason
AIInsightValue
AIPredictionEvent
AIRecordInsight
AcceptedEventRelation
Account
AccountBrand
AccountBrandShare
@surajp
surajp / sf_standard_schema.txt
Created January 28, 2021 00:09
Salesforce Standard Objects and Fields
AboutMe User
AboutMe UserChangeEvent
AcceptLanguage CredentialStuffingEvent
AcceptLanguage CredentialStuffingEventStore
AcceptanceLabel Recommendation
AcceptanceLabel RecommendationChangeEvent
AccessCode ConferenceNumber
AccessLevel AccountBrandShare
AccessLevel AssessmentIndicatorDefinitionShare
AccessLevel AssessmentTaskDefinitionShare
@surajp
surajp / CheckSeeAllData.cls
Created January 19, 2021 19:12
Check if you're running with seeAllData = true
@isTest
public static void it_should_say_seeall_is_false() {
Boolean seeAllData = true;
try {
ConnectApi.UserProfiles.getUserProfile(null, UserInfo.getUserId());
} catch (UnsupportedOperationException ex) {
seeAllData = false;
}
System.assert(!seeAllData, 'See All data returned true');
}
import { LightningElement, api, track, wire } from 'lwc';
import setupChartData from './chartSetup.js';
import getChartData from '@salesforce/apex/MachineActivityCompletionChartController.getTestCompletionDetails';
import getChartOptions from './chartOptions.js';
export default class MachineActivityCompletetionChart extends LightningElement {
@api poaId;
@api testMethodIds;
@surajp
surajp / ldsutils.js
Last active October 15, 2020 13:49
Lds Utils
/**
* Reduces one or more LDS errors into a string[] of error messages.
* @param {FetchResponse|FetchResponse[]} errors
* @return {String[]} Error messages
*/
const reduceErrors = (errors) => {
if (!Array.isArray(errors)) {
errors = [errors];
}
@surajp
surajp / ctags.sh
Created August 25, 2020 13:10
Create tags file for Apex classes
ctags --extra=+q --langmap=java:.cls.trigger -f ./tags -R force-app/main/default/classes/