Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / README.md
Last active December 8, 2023 23:34
How to create External Credentials

Step 1:

Make POST call to endpoint (/services/data/v58.0/named-credentials/external-credentials/) with below JSON body to create external credential.

{
  "authenticationProtocol": "Custom",
  "customHeaders": [],
  "developerName": "Test2",
  "masterLabel": "Test",
@sfdcale
sfdcale / sfCliReleaseInfo.sh
Last active September 20, 2023 20:40
Command to print release info for the given org
# Command to print release info for the given org
sf org display --json --target-org scratch-org | jq -r '[.result.instanceUrl,.result.accessToken] | @tsv' | \
xargs -t sh -c 'curl -i --location $1/services/data --header "Authorization: Bearer $2"' sh
@sfdcale
sfdcale / autoPublishCommunityOnLwcChanges.sh
Created July 21, 2023 19:00
Auto Publish community on LWC changes
#!/bin/bash
# Validates command line arguments to make sure everything looks correct.
validateArguments() {
if [ "$lwcFolderToWatch" = "" ] || [ "$orgUserNameOrAlias" = "" ] || [ "$communityToPublish" = "" ]; then
echo "Error: Incorrect number of arguments. Please provide exactly 3 arguments."
exit 1
fi
}
# command to find files that were modified in last 7 days in downloads folder.
# It shows prompt, asking if we want to delete.
# Useful for cleaning a directory.
find ~/Downloads -mtime -7d -type f -maxdepth 1 -exec rm -i {} \;
@sfdcale
sfdcale / findPlusGrepPlusSed.sh
Created November 10, 2022 05:42
Find + Grep + Sed
# Find for files matching specific pattern
# Check if specific text is there in that file
# Replace that specific text with other text.
find . -type f -not -iregex '.*node_modules.*' -exec grep -EHni 'abc' {} \; -exec sed -i '' -e 's/abc/xyz/g' {} \;
@sfdcale
sfdcale / useful_command.sh
Created May 1, 2022 21:20
Grep command to search for specific text in files recursively
sudo grep --color --ignore-case --extended-regexp --with-filename --regexp 'Mellbourne' --recursive --binary-files=without-match 2>/dev/null
@sfdcale
sfdcale / out.txt
Created January 20, 2022 22:52
CheckHealth output
coc: health#coc#check
========================================================================
- OK: Environment check passed
- OK: Javascript bundle build/index.js found
- OK: Service started
nvim: health#nvim#check
========================================================================
## Configuration
@sfdcale
sfdcale / gist:d4a80cb4f315be1cabb9de827a00122f
Created November 11, 2021 05:47
Sqlite - Syntax for UPDATE FROM
UPDATE
Employee
SET
Id = T2.Id // DO NOT USE Employee.Id HERE. IT FAILS.
FROM
(
SELECT
Department.Id AS Id
FROM
Department
@sfdcale
sfdcale / sfdxcurlshortcut.sh
Last active August 10, 2021 21:53
Shortcut on how to read instance url and access token from SFDX CLI and use that in curl
sfdx force:org:display --targetusername sandbox --json | jq -r '[.result.instanceUrl,.result.accessToken] | @tsv' \
| xargs -t sh -c 'curl -i --location $1/services/data/v50.0/sobjects/ContentVersion \
--header "Authorization: Bearer $2" \
--form entity_content='\''{ "PathOnClient": "Statement.pdf" };type=application/json'\'' \
--form VersionData="@Metecho Training.pdf;type=application/octset-stream;"' sh
# Make sure that there is a file named `@Metecho Training.pdf` in the location where this command is run from.
@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.