Skip to content

Instantly share code, notes, and snippets.

@gbutt
Created November 30, 2017 14:53
Show Gist options
  • Save gbutt/2a9d3c28ca34b3b929b6fe421460e779 to your computer and use it in GitHub Desktop.
Save gbutt/2a9d3c28ca34b3b929b6fe421460e779 to your computer and use it in GitHub Desktop.
Get Record Types for Scratch Org Data Load
#!/bin/sh
mkdir tmp
# get all record types and save to a file
sfdx force:data:soql:query --query "SELECT ID, DeveloperName, SObjectType FROM RecordType WHERE IsActive = true" > tmp/recordtypes.txt
# get record type id for account record type with developer name = Educational_Institution
RTID_ACCOUNT_INSTITUTION=`cat tmp/recordtypes.txt | awk ' $3 ~ /Account/ && $2 ~ /Educational_Institution/ { print $1 } ' `
# search and replace record types in csv
cp sample-data/institutions.csv tmp/institutions.csv
sed -i '' "s/Educational_Institution_RT/$RTID_ACCOUNT_INSTITUTION/g" tmp/institutions.csv
# upsert csv
sfdx force:data:bulk:upsert -u hedaScratch -s Account -f ./tmp/institutions.csv -i External_Id__c -w 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment