Created
November 30, 2017 14:53
-
-
Save gbutt/2a9d3c28ca34b3b929b6fe421460e779 to your computer and use it in GitHub Desktop.
Get Record Types for Scratch Org Data Load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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