Plugin for migrating BRE based configurator rules to CML.
npm install @salesforce/plugin-bre-to-cml  
``bash`
sf plugins install @salesforce/plugin-bre-to-cml@x.y.z
1. Please read our Code of Conduct
2. Create a new issue before starting your project so that we can keep track of
what you are trying to add/fix. That way, we can also offer suggestions or
let you know if there is already an effort in progress.
3. Fork this repository.
4. Build the plugin locally
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
6. Edit the code in your fork.
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
8. Sign CLA (see CLA below).
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
External contributors will be required to sign a Contributor's License
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
To build the plugin locally, make sure to have yarn installed and run the following commands:
`bashClone the repository
git clone git@github.com:salesforcecli/plugin-bre-to-cml
To use your plugin, run using the local
./bin/dev.js or ./bin/dev.cmd file.`bash
Run using local run file.
./bin/dev cml
`There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
`bash
Link your plugin to the sf cli
sf plugins link .
To verify
sf plugins
`Commands
sf cml convert prod-cfg-rules
- sf cml import as-expression-setsf cml convert prod-cfg-rulesConverts BRE based Standard Configurator rules represented as JSON to CML and saves it as a pair of CML and association files.
`
USAGE
$ sf cml convert prod-cfg-rules -o -r -c [--json] [--flags-dir ] [--api-version ] [-d
] [-x ] [-v ]FLAGS
-c, --cml-api= (required) Unique CML API Name to be created.
-d, --workspace-dir= Directory where working files are located, exported rules JSON and where CMLs will
be created.
-o, --target-org= (required) Username or alias of the target org. Not required if the
target-org
configuration variable is already set.
-r, --pcr-file= (required) Name of the JSON file that contain exported standard Product
Configuration Rules.
-v, --products-file= Name of the JSON file that contain exported Products from PCM (if not present
products will be fetched automatically).
-x, --additional-products= Comma-separated list of additional product IDs for which CML types should be
generated.
--api-version= Override the api version used for api requests made by this commandGLOBAL FLAGS
--flags-dir= Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Converts BRE based Standard Configurator rules represented as JSON to CML and saves it as a pair of CML and
association files.
Before you execute this command make sure to migrate you PCM or perform migration of rules within the same org.
Export BRE based Standard Configurator rules using sf data export bulk plugin and save results in a JSON file:
sf data export bulk -o breMigOrg --query "SELECT ApiName, ConfigurationRuleDefinition,Description, EffectiveFromDate,
EffectiveToDate, Id, IsDeleted, Name, ProcessScope, RuleSubType, RuleType, Sequence, Status FROM
ProductConfigurationRule WHERE RuleType = 'Configurator' AND ApiName = 'myTestBundle'" --output-file
./data/ProductConfigurationRules.json --result-format json --wait 10 --all-rows
This command executes following logic:
- Read SC Rules from the json file and build a list of
ConfiguratorRuleInput to mimic the JSON structure of
ConfigurationRuleDefinition
- Group rules by non-intersecting Product2 IDs (CMLs can’t share products)
- For each group:
- Query PCM for related products (for bundle rules) or root definitions (for others)
- Build an in-memory representation of the CML
- Apply logic to build constraints
- Serialize the in-memory CML to a blob for import as an Expression Set, save it in a cml-api.cml file.
- Create ExpressionSetConstraintObj association records pointing to the cml-api name and write them to
cml-api_associations.csv file.
- If multiple CML and association files are produced 1-N number will be appended to the names of files.EXAMPLES
$ sf cml convert prod-cfg-rules --pcr-file data/ProductConfigurationRules.json --cml-api MY_TEST --workspace-dir data --target-org breMigOrg
`sf cml import as-expression-setImports CML and associations to the target org
`
USAGE
$ sf cml import as-expression-set -o -x -c [--json] [--flags-dir ] [--api-version ] [-d
]FLAGS
-c, --cml-api= (required) Unique CML API Name to be created.
-d, --workspace-dir= Directory where converted CML and assocciations csv files are located.
-o, --target-org= (required) Username or alias of the target org. Not required if the
target-org
configuration variable is already set.
-x, --context-definition= (required) Context Definition name to be assocciated with the CML.
--api-version= Override the api version used for api requests made by this commandGLOBAL FLAGS
--flags-dir= Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Imports CML and associations to the target org
Review CM created by conversion command before doing import.
This command executes following logic:
- Import one CML at a time
- Upsert the Expression Set using the
cml-api name
- Read and upsert ExpressionSetConstraintObj rows from the cml-api_associations.csv file (resolving FKs)
- Upload the CML blobEXAMPLES
$ sf cml import as-expression-set --cml-api MY_TEST --context-definition PricingTransactionCD2 --workspace-dir data --target-org tgtOrg
``