Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / Example.java
Last active May 1, 2019 17:20
Object Permissions by Profile and Permission Sets
//Run the below query to see what access Profiles('System Administrator','Standard User') are giving to objects('Lead','Account')
SELECT sobjecttype,
Parent.Profile.Name,
permissionscreate,
permissionsdelete,
permissionsviewallrecords,
permissionsmodifyallrecords,
permissionsread,
permissionsedit
@sfdcale
sfdcale / retrieve-object-perms.sh
Created May 21, 2019 18:50 — forked from gbutt/retrieve-object-perms.sh
SFDX script to retrieve profiles and perm sets with object CRUD and FLS
#!/bin/bash
TARGET_ORG=$1
if [$TARGET_ORG == ""]; then
echo Please specify a target username
echo For a list of available usernames use: sfdx force:org:list
exit 1
fi
deleteDebugLogs(){
sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" -r "csv" > out.csv && sfdx force:data:bulk:delete -s ApexLog -f out.csv
}
extendRameshaDevTraceFlagBy24Hours() {
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 7tfM0000000Dd3R -v $temp
@sfdcale
sfdcale / DownloadLogFiles.sh
Last active September 20, 2019 04:15
This bash script is to download all log files from the environment.
#!/bin/bash
sfdx force:apex:log:list --targetusername=devsandbox --json | jq '.result[] | .Id' > apexlogids.csv
input="apexlogids.csv"
while IFS= read -r line
do
id="${line//\"/}"
echo "$id"
sfdx force:apex:log:get --logid="$id" --targetusername="devsandbox" > $id.log
done < "$input"
@sfdcale
sfdcale / QueryFlowNames.sh
Last active September 20, 2019 22:01
This bash script is to download flow id and name from input file containing flow id
#!/bin/bash
input="flows.csv"
while IFS= read -r line
do
id="${line//\"/}"
id="'$id'"
echo "$id"
sfdx force:data:soql:query --usetoolingapi --query="SELECT Id,FullName FROM Flow WHERE Id=$id" --resultformat=csv --targetusername=prod >> flow_names.csv
done < "$input"
@sfdcale
sfdcale / DeleteApexLogFiles.sh
Last active September 22, 2019 19:08
This command is to delete find and delete apex logs in system
#Deletes apex logs.
sudo find / -type f -name '07L*.log' -exec rm -i {} \;
sudo find / -type f -name 'success*.csv' -exec rm -v {} \;
@sfdcale
sfdcale / ListAllCustomFields.sh
Created September 23, 2019 02:05
This bash script is to list all the custom fields in the system as CustomField doesn't support wildcard
#!/bin/bash
extensionsToExclude=(
'History'
'__History'
'Share'
'__Share'
'ChangeEvent'
'__ChangeEvent'
)
input="ObjNames.csv"
@sfdcale
sfdcale / PrepareCompleteCustomObjectPackageXml.sh
Last active September 29, 2019 21:12
This shell script prepares package.xml file with all of the custom objects present in the org
#!/bin/bash
sfdx force:mdapi:listmetadata --metadatatype=CustomObject --targetusername=sandbox --json | jq '.result[].fullName' > temp.txt
input="temp.txt"
rm -f package_temp.xml
echo "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n" >> package_temp.xml
echo "<Package xmlns=\"http://soap.sforce.com/2006/04/metadata\">" >> package_temp.xml
echo " <types>" >> package_temp.xml
while IFS= read -r line
do
objName="${line//\"/}"
@sfdcale
sfdcale / PrepareEmailTemplatePackaXml.sh
Last active September 29, 2019 21:11
This shell script prints all EmailTemplate components present in the org.
#!/bin/bash
sfdx force:mdapi:listmetadata --metadatatype=EmailFolder --targetusername=devcrm --json | jq '.result[].fullName' > temp.txt
input="temp.txt"
rm -f package_temp.xml
echo "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n" >> package_temp.xml
echo "<Package xmlns=\"http://soap.sforce.com/2006/04/metadata\">" >> package_temp.xml
echo " <types>" >> package_temp.xml
while IFS= read -r line
do
folderName="${line//\"/}"
@sfdcale
sfdcale / DownloadMetadataInSourceFormat.sh
Last active October 3, 2019 18:30
This shell script prepares package.xml file and downloads metadata in source format.
#!/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