Skip to content

Instantly share code, notes, and snippets.

View shanerk's full-sized avatar
Wizards only, fools!

Shane K shanerk

Wizards only, fools!
View GitHub Profile
@shanerk
shanerk / destroy.sh
Created March 22, 2024 18:47
Bash script to perform destructive changes against a Salesforce Org based on a GIT diff
#!/bin/bash
cleanExit() {
#rm dchanges.txt*
exit
}
QUICK=false
while [[ $# -gt 0 ]]; do
@shanerk
shanerk / clean_deleted_git_branches.ps1
Last active March 18, 2024 19:25
Cleanup deleted branches (PowerShell)
# Step 1: git fetch -p
git fetch -p
# Step 2: git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == "[gone]" {print $1}' | xargs git branch -D
git for-each-ref --format '%(refname:short) %(upstream:track)' | Where-Object { $_.Split(' ')[1] -eq '[gone]' } | ForEach-Object { git branch -D $_.Split(' ')[0] }
@shanerk
shanerk / diffclip.sh
Last active March 27, 2023 16:53
Git Diff to Clipboard
#Linux / OSX / ZSH
git diff main --name-status | pbcopy
#Windows Powershell
git diff main --name-status | scb
#Windows CMD
git diff main --name-status | clip
@shanerk
shanerk / clean_deleted_git_branches.sh
Last active March 18, 2024 19:25
Cleanup Local Branches which were deleted on the remote
git fetch -p
git for-each-ref --format '%(refname:short) %(upstream:track)' |
awk '$2 == "[gone]" {print $1}' |
xargs git branch -D
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default ruleset used by the CodeClimate Engine for Salesforce.com Apex" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>Default ruleset used by the Code Climate Engine for Salesforce.com Apex</description>
<exclude-pattern>.*/.sfdx/.*</exclude-pattern>
<!-- COMPLEXITY
<rule ref="category/apex/design.xml/ExcessiveClassLength" message="Avoid really long classes (lines of code)">
<priority>3</priority>
<properties>
<property name="minimum" value="1000" />
</properties>
Description:
These profiles are not supposed to be accessible as they are used for App Exchange packages.
When you go to the Package License Manager profile as an Org Admin, it tells you that you don't have sufficient privileges to change that profile.
But the page we really need to get to is the Profile Record Type edit page.
@shanerk
shanerk / deploy.sh
Last active March 22, 2024 18:41
Deploy to Salesforce with GIT Changeset (-d flag runs against HEAD and default org with no confirmations)
#!/bin/bash
cleanExit() {
rm changes.txt*
exit
}
QUICK=false
while [[ $# -gt 0 ]]; do
@shanerk
shanerk / get_mdt.sh
Created May 20, 2020 20:21
Pull down all custom metadata records for a Salesforce org and unpack them into the DX format
# Pull down all custom metadata records for a Salesforce org and unpack them into the DX format
# Run from the root of your Salesforce DX project, the script assumes that your project is a git repo
#!/bin/bash
mkdir .tmp
echo '<?xml version="1.0" encoding="UTF-8"?><Package xmlns="http://soap.sforce.com/2006/04/metadata"><types><name>CustomMetadata</name><members>*</members></types><version>41.0</version></Package>' > .tmp/package.xml
echo 'Retrieving metadata from Salesforce...'
sfdx force:mdapi:retrieve --retrievetargetdir .tmp/ --wait 5 --unpackaged .tmp/package.xml
@shanerk
shanerk / getChildRelations.cls
Created May 18, 2020 19:50
Gets list child relation API names based on the child object type (Salesforce Apex)
// Gets list child relation API names based on the child object type (Salesforce Apex)
//
DescribeSObjectResult type = SobjectType.Account;
String filter = 'Feed';
for (ChildRelationship relation : type.getChildRelationships()) {
if (String.valueOf(relation).contains(filter))
system.debug('* ' + relation.getChildSObject() + ' = ' + relation.getRelationshipName());
}

Steps to Create DX Package Versions

Get Package Id

First you need the Package Id for your package. Package details can be obtained as follows:

sfdx force:package:version:report -p YOUR_PACKAGE_NAME

Ensure your sfdx-project.json has the Package ID and not the Subscriber Package Version Id set in this section: