Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Created September 23, 2019 02:05
Show Gist options
  • Select an option

  • Save sfdcale/6fe61b55f7114581f3e002469f6ba338 to your computer and use it in GitHub Desktop.

Select an option

Save sfdcale/6fe61b55f7114581f3e002469f6ba338 to your computer and use it in GitHub Desktop.
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"
rm CustomFields.txt
touch CustomFields.txt
while IFS= read -r objName
do
echo $objName
excludeObject=false
for objExt in "${extensionsToExclude[@]}"
do
if [[ $objName == *"$objExt" ]]; then
echo "Skipping $objName"
excludeObject=true
break
fi
done
if [[ $excludeObject == false ]]; then
echo "proceeding with $objName"
sfdx force:schema:sobject:describe --targetusername=prod --sobjecttype=$objName --json | jq -r --arg objName $objName '.result.fields[] | $objName + "." + .name' >> CustomFields.txt
fi
done < "$input"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment