Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Last active October 7, 2020 20:12
Show Gist options
  • Select an option

  • Save sfdcale/0629def5173f0701f47f68ce10514949 to your computer and use it in GitHub Desktop.

Select an option

Save sfdcale/0629def5173f0701f47f68ce10514949 to your computer and use it in GitHub Desktop.

Run this script passing object name and field api name(without __c) and it prints all the metadata about the custom field like "Description","inlinehelpText" and etc..

sh GetFieldInfo.sh Foo__c bar

NOTE: This script only works with custom fields.

#!/bin/bash
sfdx force:data:soql:query --query="SELECT Id,NameSpacePrefix, DeveloperName, TableEnumOrId,Metadata FROM CustomField WHERE TableEnumOrId = '$1' and DeveloperName='$2'" --usetoolingapi --targetusername cxuat --json > temp.txt
echo 'printing picklist values'
cat temp.txt | jq '.result.records[0].Metadata.valueSet.valueSetDefinition.value[]' | jq '.valueName'
echo '-------------------------'
echo 'printing description'
cat temp.txt | jq '.result.records[0].Metadata.description'
echo '-------------------------'
echo 'printing inlineHelpText'
cat temp.txt | jq '.result.records[0].Metadata.inlineHelpText'
echo '-------------------------'
echo 'printing formula'
cat temp.txt | jq '.result.records[0].Metadata.formula'
echo '-------------------------'
echo 'printing label'
cat temp.txt | jq '.result.records[0].Metadata.label'
echo '-------------------------'
echo 'printing type'
cat temp.txt | jq '.result.records[0].Metadata.type'
echo '-------------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment