Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / InsertBlobIntoContentVersion.sh
Created August 10, 2021 04:23
How to Insert Blob data into ContentVersion using curl
curl -i --location https://acme.my.salesforce.com/services/data/v50.0/sobjects/ContentVersion \
--header "Authorization: Bearer 00D051234564atA!abcdef" \
--form entity_content='{ "PathOnClient": "Statement.pdf" };type=application/json' \
--form VersionData="@Statement.pdf;type=application/octset-stream;"
# Make sure that there is a file named `Statement.pdf` in the directory where this command is run from.
@sfdcale
sfdcale / Readme.md
Last active July 6, 2021 02:28
How to Reduce pdf size
@sfdcale
sfdcale / README.md
Last active January 10, 2021 05:18
Docker Ubuntu instrcutions
  1. Paste the below code in file named Dockerfile
FROM ubuntu
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
    && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8


RUN apt-get update
RUN apt-get install -y sudo
#!/bin/bash
FEED_ITEM_TYPES=("ContentPost" "TextPost" "ActivityEvent" "AdvancedTextPost" "AnnouncementPost" "ApprovalPost" "BasicTemplateFeedItem" "CanvasPost" "CollaborationGroupCreated" "CollaborationGroupUnarchived" "ContentPost" "CreatedRecordEvent" "DashboardComponentAlert" "DashboardComponentSnapshot" "LinkPost" "PollPost" "ProfileSkillPost" "QuestionPost" "ReplyPost" "RypplePost" "TextPost" "TrackedChange" "UserStatus" "AttachArticleEvent" "CallLogPost" "CaseCommentPost" "ChangeStatusPost" "ChatTranscriptPost" "EmailMessageEvent" "FacebookPost" "MilestoneEvent" "SocialPost")
DATE_LOWER_BOUND=""
DATE_BOUND_VALUES=("2011-12-31" "2012-12-31" "2013-12-31" "2014-12-31" "2015-12-31" "2016-12-31" "2017-12-31" "2018-12-31" "2019-12-31" "2020-12-31")
for FEED_ITEM_TYPE in ${FEED_ITEM_TYPES[@]}; do
TOTAL_COUNT=0
#!/bin/bash
sfdx force:data:soql:query --query="SELECT Id,NameSpacePrefix, DeveloperName, TableEnumOrId,Metadata FROM CustomField WHERE TableEnumOrId = '$1' and DeveloperName='$2'" --usetoolingapi --targetusername cxuat --json > temp.txt
echo 'printing picklist values'
cat temp.txt | jq '.result.records[0].Metadata.valueSet.valueSetDefinition.value[]' | jq '.valueName'
echo '-------------------------'
@sfdcale
sfdcale / .zshrc
Last active April 23, 2020 22:50
Store this command in ~/.zshrc to delete files
cleanUpDirectory(){
if [ $# -lt 1 ]; then
echo 1>&2 "$0: not enough arguments"
return
fi
find -E $1 -type f -maxdepth 1 -regex '.*\.(jpg|png|csv|txt|jpeg|dmg|pdf)' -exec rm -i {} \;
}
find / -type f -name '*.py' 2>/dev/null -exec grep --color --extended-regexp --with-filename --regexp 'access_token,' {} \;
find ../ -type f -regex '.*.js' -not -regex '.*node\_modules.*' -exec grep -EHni --color "\*\*\*" {} \;
@sfdcale
sfdcale / ExtendDebugLogs.sh
Created April 6, 2020 22:24
Extend Debug log expiration time without going into the setup screen.
StartDate=$(date -u +%Y-%m-%dT%H:%M:%S.000+0000)
ExpirationDate=$(date -u -v+24H +%Y-%m-%dT%H:%M:%S.000+0000)
#echo "StartDate=$StartDate ExpirationDate=$ExpirationDate"
temp="StartDate=$StartDate ExpirationDate=$ExpirationDate"
sfdx force:data:record:update -t -s TraceFlag -i <traceFlagIdGoesHere> -v $temp --targetusername=prod
echo "Extended debug logs for Ramesh Ale"
#!/bin/bash
prepare_wildcard_package (){
echo " <types>" >> package_temp.xml
echo " <members>*</members>" >> package_temp.xml
echo " <name>$1</name>" >> package_temp.xml
echo " </types>" >> package_temp.xml
}
rm -f temp.txt
@sfdcale
sfdcale / prepareEmailMessageList.java
Last active March 5, 2020 22:51
This sample code attaches EmailMessage to Account record with content of EmailTemplate
public static List<EmailMessage> prepareEmailMessageList(List<Account> accList){
List<EmailMessage> emailMsgList = new List<EmailMessage>();
EmailTemplate templateObj = [SELECT Id,Name,Subject,Body,HtmlValue,Markup FROM EmailTemplate WHERE Name = 'Statement Template' LIMIT 1];
for(Account accObj: accList){
EmailMessage emailMsgObj = new EmailMessage();
emailMsgObj.status = '3'; // email was sent
emailMsgObj.relatedToId = accObj.Id;
emailMsgObj.fromAddress = 'Billing.Support@acme.com'; // from address
emailMsgObj.fromName = 'Billing Services'; // from name
@sfdcale
sfdcale / removeNonWritableColumnsFromTalendSchemaXml.py
Last active January 21, 2020 17:25
This python script is to remove formula and system columns from Talend schema file
import subprocess
import os
import shutil
import xml.etree.ElementTree as ET
objectName = 'SBQQ__ConfigurationRule__c'
command = "sfdx force:schema:sobject:describe --sobjecttype=" + objectName + " --targetusername=TEST --json | jq '.result.fields[]' | jq '.name' | jq -s ."
commandOutput = subprocess.check_output(command,shell=True)