-
Notifications
You must be signed in to change notification settings - Fork 2
Recipes
Christian G. Warden edited this page Sep 20, 2024
·
8 revisions
Many of these examples use GNU Parallel to perform many operations. Some also use the force cli.
$ force-md objects fields list -k src/objects/My_Object__c.object | parallel -P1 force-md objects fields edit -K -f {} src/objects/My_Object.object
# Create a new temporary package.xml
$ force-md package new /tmp/package.xml
# Add the metadata that need to fetch to the package.xml
$ force-md package add -t CustomObject -n Account /tmp/package.xml
$ force-md package add -t Profile -n '*' /tmp/package.xml
# Retrieve the new metadata to a temporary directory
$ force fetch -x /tmp/package.xml -d new
# Merge the (Account field permissions from) new profiles into the existing profiles
ls src/profiles/* | parallel 'force-md profile merge -s new/profiles/{/} {}'
# Create a new temporary package.xml
$ force-md package new /tmp/package.xml
# Add the object and profile metadata that need to fetch to the package.xml
$ force-md package add -t Profile -n '*' /tmp/package.xml
$ force describe -t sobject | grep -Ev '__(ChangeEvent|Share|History)$' | parallel -P1 force-md package add -t CustomObject -n {} /tmp/package.xml
# Retrieve the metadata
$ force fetch -x /tmp/package.xml
# Remove read and edit access from all fields
$ force-md profile field-permissions list src/profiles/* | cut -f1 -d: | sort -u | parallel -P1 'force-md profile field-permissions edit --field {} --no-read --no-edit src/profiles/*'
# Deploy the updated profiles
$ force push src/profiles/*
$ force-md package new src/destructiveChanges.xml
$ ls src/flows/* | parallel "force query -f json \"SELECT Status, FlowDefinitionView.ApiName, VersionNumber FROM FlowVersionView WHERE FlowDefinitionView.ApiName = '{/.}'\"" \
| jq -r 'select(.Status == "Obsolete") | (.FlowDefinitionView.ApiName + "-" + (.VersionNumber|tostring))' \
| parallel -P1 force-md package add -t Flow -n {} src/destructiveChanges.xml
$ force push -i src/destructiveChanges.xml
$ force-md objects recordtype list src/objects/* | parallel -P1 'force-md profile recordtype add -r {} src/profiles/*'
$ force-md custommetadata table -i dlrs__AggregateOperation__c -i dlrs__AggregateResultField__c -i dlrs__ChildObject__c -i dlrs__RelationshipField__c -i dlrs__RelationshipCriteria__c -i dlrs__RelationshipCriteriaFields__c -i dlrs__ParentObject__c -i dlrs__FieldToAggregate__c sfdx/main/default/customMetadata/dlrs__LookupRollupSummary2.*