Skip to content
ForceCLIPublic

About

Manipulate Salesforce Metadata

Resources

Stars

7 stars

Watchers

1 watching

Forks

Latest commit

 

History

618 Commits

Folders and files

Repository files navigation

force-md

Manipulate Salesforce metadata.

Usage

See docs/force-md.md for all supported commands.

The commands are long, but tab completion makes them relatively painless. Enable bash completion or see force-md completion --help for other options.

$ source <(force-md completion bash)

Examples

Below are some basic examples. See the wiki for higher level examples.

Tidy Permission Sets

Clean up metadata by sorting groups of elements in natural order.

$ force-md permissionset tidy src/permissionsets/*

Tidy All Metadata In A Directory

Tidy every tidyable metadata file in a directory and its subdirectories, and format every Apex class (.cls) and trigger (.trigger) with apexfmt. Files that are not metadata and hidden directories such as .git are skipped, and an Apex file that apexfmt cannot parse is reported and left unchanged. Add -l to list the files that need tidying or formatting without changing them.

$ force-md tidy -r force-app/main/default

Clone Field Permissions

Add field permissions for a new field to Permission Sets by copying the permissions from another field.

$ force-md permissionset field-permissions clone -s Account.My_Field__c -f Account.New_Field__c src/permissionsets/*

Merge Permission Sets

Grant all permissions from a source permission set to another permission set.

$ force-md permissionset merge -s src/permissionsets/Subset.permissionset src/permissionsets/Superset.permissionset

Add Class

Enable access to an apex class

$ force-md permissionset apex add -c MyClass src/permissionsets/My_Permission_Set.permissionset

Add Tab

Enable tab visibility

$ force-md permissionset tab add -t My_Tab src/permissionsets/My_Permission_Set.permissionset

Add Object Permissions to Profiles

Add object permissions to Profiles. All permissions will default to false; use profile object-permissions edit to update.

$ force-md profile object-permissions add -o Account src/profiles/*

Update Object Permissions

Update the Read, Create, Edit, Delete, View All, and Modify All permissions on Profiles. Any permissions not specified on the command line will be left unchanged.

$ force-md profile object-permissions edit -o Account -e -D src/profiles/*

Copy and Convert Metadata

Copy metadata between source format (SFDX) and metadata format (MDAPI). Automatically handles merging/splitting of CustomObjects and CustomObjectTranslations.

$ force-md copy src -t sfdx -f source      # Convert from metadata to source format
$ force-md copy sfdx -t src -f metadata    # Convert from source to metadata format
$ force-md copy src -t sfdx -f source -x package.xml  # Convert with package.xml filter

The -x flag allows filtering metadata based on a package.xml file:

  • Named components: Only the specified components are copied
  • Wildcards (*): All components of that type are copied
  • Mixed (wildcards + named): All components are copied, but fails if any named component is missing

Developing

To add support for a new metadata type, zek can be useful for getting started by generating a struct that matches the XML structure, e.g.

$ zek -C -m src/queues/*

About

Manipulate Salesforce Metadata

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages