Skip to content

shuntaro-sf/sfdx-metadata-generator

Repository files navigation

sfdx-metadata-generator

The plugin is deplicated and moved to the new sf repository

sf-metadata-generator

sfdx-metadata-generator

SFDX plugin to generate metadata

Version CircleCI Appveyor CI Greenkeeper Known Vulnerabilities Downloads/week License

$ npm install -g @shuntaro/sfdx-metadata-generator
$ sfdx COMMAND
running command...
$ sfdx (--version)
@shuntaro/sfdx-metadata-generator/3.7.1 win32-x64 node-v18.16.0
$ sfdx --help [COMMAND]
USAGE
  $ sfdx COMMAND
...

sfdx metadata:field:convert [-s <string>] [-o <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Converts custom-field-xml-files to a file used to create or update the metadata.

USAGE
  $ sfdx metadata:field:convert [-s <string>] [-o <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -s, --sourcedir=<value>                                                           directory where source files you
                                                                                    convert are stored
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Converts custom-field-xml-files to a file used to create or update the metadata.

EXAMPLES
  $ sfdx metadata:field:convert --sourcedir ./sourcedir/ --outputdir ./outputdir/

See code: src/commands/metadata/field/convert.ts

sfdx metadata:field:generate [-i <string>] [-o <string>] [-u] [-d <string>] [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Generates custom field metadata converting values in any sort of spreadsheets, e.g., csv and to xml files.

USAGE
  $ sfdx metadata:field:generate [-i <string>] [-o <string>] [-u] [-d <string>] [-p <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -d, --delimiter=<value>                                                           delimiter for the input file. the
                                                                                    default value is comma
  -i, --input=<value>                                                               input file to be converted to xml
                                                                                    files
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -p, --picklistdelimiter=<value>                                                   delimiter for picklist fullNames and
                                                                                    labels. the default value is
                                                                                    semicolon
  -u, --updates                                                                     whether update existing xml files in
                                                                                    outputdir or not
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Generates custom field metadata converting values in any sort of spreadsheets, e.g., csv and  to xml files.

EXAMPLES
  $ sfdx metadata:field:generate --input ./input.csv --outputdir ./outputdir/

See code: src/commands/metadata/field/generate.ts

sfdx metadata:field:template [-o <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Creates a template input-csv-file.

USAGE
  $ sfdx metadata:field:template [-o <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --outputdir=<value>                                                           directory where a template csv file
                                                                                    is saved.
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Creates a template input-csv-file.

EXAMPLES
  $ sfdx metadata:field:template --outputdir ./outputdir/

See code: src/commands/metadata/field/template.ts

sfdx metadata:object:convert [-s <string>] [-o <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Converts custom-object-xml-files to a file used to create or update the metadata.

USAGE
  $ sfdx metadata:object:convert [-s <string>] [-o <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -s, --sourcedir=<value>                                                           directory where source files you
                                                                                    convert are stored
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Converts custom-object-xml-files to a file used to create or update the metadata.

EXAMPLES
  $ sfdx metadata:object:convert --sourcedir ./sourcedir/ --outputdir ./outputdir/

See code: src/commands/metadata/object/convert.ts

sfdx metadata:object:generate [-i <string>] [-o <string>] [-u] [-d <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Generates custom field metadata converting values in any sort of spreadsheets, e.g., csv and to xml files.

USAGE
  $ sfdx metadata:object:generate [-i <string>] [-o <string>] [-u] [-d <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -d, --delimiter=<value>                                                           delimiter for the input file. the
                                                                                    default value is comma
  -i, --input=<value>                                                               input file to be converted to xml
                                                                                    files
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -u, --updates                                                                     whether update existing xml files in
                                                                                    outputdir or not
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Generates custom field metadata converting values in any sort of spreadsheets, e.g., csv and  to xml files.

EXAMPLES
  $ sfdx metadata:field:generate --input ./input.csv --outputdir ./outputdir/

See code: src/commands/metadata/object/generate.ts

sfdx metadata:object:template [-o <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Creates a template input-csv-file.

USAGE
  $ sfdx metadata:object:template [-o <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --outputdir=<value>                                                           directory where a template csv file
                                                                                    is saved.
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Creates a template input-csv-file.

EXAMPLES
  $ sfdx metadata:object:template --outputdir ./outputdir/

See code: src/commands/metadata/object/template.ts

sfdx metadata:profile:convert [-s <string>] [-o <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Converts custom-profile-xml-files to a file used to update the metadata.

USAGE
  $ sfdx metadata:profile:convert [-s <string>] [-o <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -s, --source=<value>                                                              directory where source files you
                                                                                    convert are stored
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Converts custom-profile-xml-files to a file used to update the metadata.

EXAMPLES
  $ sfdx metadata:profile:convert --source ./source --outputdir ./outputdir/

See code: src/commands/metadata/profile/convert.ts

sfdx metadata:profile:generate [-i <string>] [-o <string>] [-s <string>] [-d <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

Updates profile metadata converting values in any sort of spreadsheets, e.g., csv and to xml files.

USAGE
  $ sfdx metadata:profile:generate [-i <string>] [-o <string>] [-s <string>] [-d <string>] [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -d, --delimiter=<value>                                                           delimiter for the input file. the
                                                                                    default value is comma
  -i, --input=<value>                                                               input file to be converted to xml
                                                                                    files
  -o, --outputdir=<value>                                                           output directory where metadata are
                                                                                    saved
  -s, --source=<value>                                                              directory where source files you
                                                                                    convert are stored
  --json                                                                            format output as json
  --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)  [default: warn] logging level for
                                                                                    this command invocation

DESCRIPTION
  Updates profile metadata converting values in any sort of spreadsheets, e.g., csv and  to xml files.

EXAMPLES
  $ sfdx metadata:profile:generate --input ./input.csv --source ./source.profile-meta.xml --outputdir ./outputdir/

See code: src/commands/metadata/profile/generate.ts

How to get started

Make sure you have already installed this plugin.

Field metadata

To start generating field metadata, you need a csv file to include tab names e.g., fullName, label, type, ... , at the header and values for those tags to determine each detail of custom fields from the second line.

Other spreadsheet files are also supported as delimiter flag on the generator command can be any string.

The description of each tag is as follows. For further details of custrom-field-metadata, see https://developer.salesforce.com/docs/atlas.en-us.242.0.api_meta.meta/api_meta/customfield.htm

Tag Description
fullName Custom field API name.
label Field label name.
description Field descritpion.
inlineHelpText Field-level help text.
type Data type. Options are listed below:
AutoNumber, Checkbox, Currency, Date, DateTime, Email, Location, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, LongTextArea, Html, EncryptedText, Time, Url, Lookup, MasterDetail, ExternalLookup, Summary.
required Whether it is required. Options are listed below:
true, false.
externalId Whether it is an external ID. Options are listed below:
true, false.
trackHistory Whether to enableck history tracking. Options are listed below:
true, false.
trackTrending Whether to track historical trending. Options are listed below:
true, false.
unique Whether it is unique. Options are listed below:
true, false.
defaultValue Default value. For Checkbox data type. Options are listed below:
true, false.
displayFormat Display format for AutoNumber. Example: A-{0000}.
displayLocationInDecimal Whether to display location in decimal. Options are listed below:
true, false.
scale Number of decimal places.
precision Number of digits.
visibleLines Number of visible lines applied to MultiselectPicklist, LongTextArea, and Html.
length Text length applied to Text, TextArea, LongTextArea, and Html.
maskChar Mask character applied to EncryptedText. Options are listed below:
asterisk, X.
maskType Mask type applied to EncryptedText. Options are listed below:
all, lastFour, creditCard, nino, ssn, sin.
picklistFullName Picklist API Names applied to Picklist and MultiselectPicklist. Note that semicolon ';' is used as the default delimiter to separate character string to multiple names. The delimiter can be chenged giving the picklistdelimiter.
picklistLabel Picklist labels applied to Picklist and MultiselectPicklist. Note that semicolon ';' is used as the default delimiter to separate character string to multiple labels. The delimiter can be chenged giving the picklistdelimiter.
caseSensitive Whether the field is case-sensitive. Applied only for Text. Options are listed below:
true, false.
referenceTo Object FullName that the object of this field references to.
relationshipLabel Label for relationship.
relationshipName Child relationship name applied for Lookup, MasterDetail, and ExternalLookup.
relationshipOrder Order of master-detail relationship. Options are listed below:
0, 1.
deleteConstraint Deletion options for lookup relationships. Options are listed below:
Cascade, Restrict, SetNull.
reparentableMasterDetail Whether the child records in a master-detail relationship on a custom object can be reparented to different parent records. Options are listed below:
true, false.
writeRequiresMasterRead Whether to allow users with Read access to the primary record permission to create, edit, or delete child records. Options are listed below:
true, false.
summaryForeignKey Represents the master-detail field on the child that defines the relationship between the parent and the child. Example: ChildObject.ParentObject.
summaryOperation Type of operation for roll-up summary field. Options are listed below:
count, sum, min, max.
summarizedField Represents the field on the detail row that is being summarized. Example: ChildObject.Field.
summaryFilterItemsField Represents the field to filter items.
summaryFilterItemsOperation Type of comparison operation to filter items. Options are listed below:
equals,notEqual,lessThan,greaterThan,lessOrEqual,greaterOrEqual,contains,notContain,startsWith,includes,excludes,within.
summaryFilterItemsValue Value to compare with summaryFilterItemsField.

Or you can create a template file running the following commnad:

  $ sfdx metadata:field:template --outputdir ./outputdir/

Then, sfdx metadata:field:generate generates custom field metadata of the input-csv-file.

The flag --input specifies the input-csv-file to be converted to metadata-xml-files and --outputdir the directory to save those xml files.

  $ sfdx metadata:field:generate --input ./input.csv --outputdir ./outputdir/

You can also update custom-field-xml-files with sfdx metadata:field:convert. Assume you have created SFDX project and retrieved field-xml files you want to update. Then, run the following command to rewrite the files in the csv format.

  $ sfdx metadata:field:convert -sourcedir ./force-app/main/default/objects/Account/fields/ --outputdir ../outputdir/

Edit the craeted csv file as you want to update metadata, and then run sfdx metadata:field:generate --updates to override the xml files.

Note that runnning without --updates avoids overrinding existing metadata.

  $ sfdx metadata:field:generate --input ./input.csv --outputdir ./outputdir/ --updates

Object metadata

To start generating object metadata, you need a csv file to include tab names e.g., fullName, label, allowInChatterGroups, ... , at the header and values for those tags to determine each detail of custom objects from the second line.

Other spreadsheet files are also supported as delimiter flag on the generator command can be any string.

The description of each tag is as follows. For further details of custrom-object-metadata, see https://developer.salesforce.com/docs/atlas.en-us.242.0.api_meta.meta/api_meta/customobject.htm

Tag Description
fullName Custom object API name.
label Custom object label name.
description Object descritpion.
allowInChatterGroups Whether to allow records of this custom object type to be added to Chatter groups. Options are listed below:
true, false.
deploymentStatus Deployment status. Options are listed below:
Deployed, InDevelopment.
enableActivities Whether to enable activities. Options are listed below:
true, false.
enableBulkApi Whether to enable bulk API. Options are listed below:
true, false.
enableHistory Whether to enable history. Options are listed below:
true, false.
enableReports Whether to enable reports. Options are listed below:
true, false.
enableSearch Whether to enable search. Options are listed below:
true, false.
enableSharing Whether to enable sharing. Options are listed below:
true, false.
enableStreamingApi Whether to enable sreaming API. Options are listed below:
true, false.
nameFieldType Type of name field. Options are listed below:
Text, AutoNumber.
nameFieldLabel Label for name field.
nameFieldDisplayFormat Name field display format. Applied when nameFieldType is set to AutoNumber.

Or you can create a template file running the following commnad:

  $ sfdx metadata:object:template --outputdir ./outputdir/

Then, sfdx metadata:object:generate generates custom object metadata of the input-csv-file.

The flag --input specifies the input-csv-file to be converted to metadata-xml-files and --outputdir the directory to save those xml files.

  $ sfdx metadata:object:generate --input ./input.csv --outputdir ./outputdir/

You can also update custom-object-xml-files with sfdx metadata:object:convert. Assume you have created SFDX project and retrieved object-xml files you want to update. Then, run the following command to rewrite the files in the csv format.

  $ sfdx metadata:object:convert -sourcedir ./force-app/main/default/objects/ --outputdir ../outputdir/

Edit the craeted csv file as you want to update metadata, and then run sfdx metadata:object:generate --updates to override the xml files.

Note that runnning without --updates avoids overrinding existing metadata.

  $ sfdx metadata:object:generate --input ./input.csv --outputdir ./outputdir/ --updates

Profile metadata

Only update is supported for profile metadata due to dependencies on other metadata.

You can rewrite a profile xml file in the csv format as shown in field metadata by runnning metadata:field:convert.

  $ sfdx metadata:field:convert -sourcedir ./force-app/main/default/profiles/xxx.profile-meta.xml --outputdir ../outputdir/

Edit the craeted csv file as you want to update metadata. The description of the output csv file is as follows. For further details of profile-metadata, see https://developer.salesforce.com/docs/atlas.en-us.242.0.api_meta.meta/api_meta/meta_profile.htm

Tag Description
fullName FullName to update.
type Field Name to update. Options are listed below:
applicationVisibilities, classAccesses, fieldPermissions, objectPermissions, pageAccesses, recordTypeVisibilities, tabVisibilities, userPermissions.
editable Whether it is allowed to edit the field of fullName. Options are listed below:
true, false.
readable Whether it is allowed to read the field of fullName. Options are listed below:
true, false.
allowCreate Whether it is allowed to create the object of fullName. Options are listed below:
true, false.
allowDelete Whether it is allowed to delete the object of fullName. Options are listed below:
true, false.
allowEdit Whether it is allowed to edit the object of fullName. Options are listed below:
true, false.
allowRead Whether it is allowed to read the object of fullName. Options are listed below:
true, false.
modifyAllRecords Whether it is allowed to modify all records of the object of fullName.Options are listed below:
true, false.
viewAllRecords Whether it is allowed to view all records of the object of fullName. Options are listed below:
true, false.
default Whether it is default. Applied for applicationVisibilities and recordTypeVisibilities. Options are listed below:
true, false.
visible Whether it is visible. Applied for applicationVisibilities and recordTypeVisibilities. Options are listed below:
true, false.
enabled Whether it is enabled. Applied for classAccesses, pageAccesses, and userPermissions. Options are listed below:
true, false.
visibility Type of tag-visibility. Applied for tabVisibilities. Options are listed below:
DefaultOn, DefaultOff,Hidden

Then, run sfdx metadata:profile:generate --updates to override the profile xml file.

  $ sfdx metadata:profile:generate --input ./input.csv --outputdir ../outputdir/