Skip to content

Commit

Permalink
Added StatusCategory flag for ContractStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienTaillon committed Jan 18, 2021
1 parent a1241e9 commit 5c34266
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Install npm modules: npm install
Link the plugin: sfdx plugins:link .

<!-- commands -->
* [`sfdx texei:contractstatus:value:add -l <string> -a <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeicontractstatusvalueadd--l-string--a-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx texei:contractstatus:value:add -l <string> -a <string> [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeicontractstatusvalueadd--l-string--a-string--s-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx texei:data:export -d <string> [-o <string>] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataexport--d-string--o-string--p-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx texei:data:import -d <string> [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataimport--d-string--a--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx texei:data:plan:generate -d <string> -o <string> [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataplangenerate--d-string--o-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
Expand All @@ -37,14 +37,14 @@ Link the plugin: sfdx plugins:link .
* [`sfdx texei:source:layouts:cleanorg [-p <string>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeisourcelayoutscleanorg--p-string--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)
* [`sfdx texei:user:update [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeiuserupdate--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal)

## `sfdx texei:contractstatus:value:add -l <string> -a <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
## `sfdx texei:contractstatus:value:add -l <string> -a <string> [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

add a value to Contract Status picklist

```
USAGE
$ sfdx texei:contractstatus:value:add -l <string> -a <string> [-u <string>] [--apiversion <string>] [--json]
[--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
$ sfdx texei:contractstatus:value:add -l <string> -a <string> [-s <string>] [-u <string>] [--apiversion <string>]
[--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-a, --apiname=apiname (required) API Name of the Contract
Expand All @@ -53,6 +53,9 @@ OPTIONS
-l, --label=label (required) label of the Contract
Status value to add
-s, --statuscategory=Draft|Activated|InApprovalProcess [default: Draft] Status Category of
the Contract Status value to add
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
Expand All @@ -69,7 +72,7 @@ EXAMPLE
--targetusername texei
```

_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/contractstatus/value/add.ts)_
_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/contractstatus/value/add.ts)_

## `sfdx texei:data:export -d <string> [-o <string>] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -105,7 +108,7 @@ EXAMPLES
sfdx texei:data:export --dataplan ./data/data-plan.json --outputdir ./data --targetusername texei
```

_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/export.ts)_
_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/export.ts)_

## `sfdx texei:data:import -d <string> [-a] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -140,7 +143,7 @@ EXAMPLE
Data imported!
```

_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/import.ts)_
_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/import.ts)_

## `sfdx texei:data:plan:generate -d <string> -o <string> [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -167,7 +170,7 @@ EXAMPLE
$ sfdx texei:data:plan:generate --objects Account,Contact,MyCustomObject__c --outputdir ./data
```

_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/plan/generate.ts)_
_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/plan/generate.ts)_

## `sfdx texei:org:contractfieldhistory:fix [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -195,7 +198,7 @@ EXAMPLE
History tracking fixed.
```

_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/org/contractfieldhistory/fix.ts)_
_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/org/contractfieldhistory/fix.ts)_

## `sfdx texei:org:shape:extract [-d <string>] [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -230,7 +233,7 @@ EXAMPLE
$ sfdx texei:org:shape:extract -u [email protected]"
```

_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/org/shape/extract.ts)_
_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/org/shape/extract.ts)_

## `sfdx texei:package:dependencies:install [-k <string>] [-b <string>] [-p <string>] [-s <string>] [-n <string>] [-w <number>] [-r] [-a <string>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -293,7 +296,7 @@ EXAMPLE
$ texei:package:dependencies:install -u MyScratchOrg -v MyDevHub -k "1:MyPackage1Key 2: 3:MyPackage3Key" -b "DEV"
```

_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/package/dependencies/install.ts)_
_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/package/dependencies/install.ts)_

## `sfdx texei:profile:clean [-k <string>] [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -327,7 +330,7 @@ EXAMPLES
custom-sfdx-source-folder/main/profiles,source-folder-2/main/profiles/myAdmin.profile-meta.xml
```

_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/profile/clean.ts)_
_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/profile/clean.ts)_

## `sfdx texei:sharedactivities:enable [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -354,7 +357,7 @@ EXAMPLE
$ sfdx texei:sharedactivities:enable
```

_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharedactivities/enable.ts)_
_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharedactivities/enable.ts)_

## `sfdx texei:sharingcalc:recalculate [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -385,7 +388,7 @@ EXAMPLE
Recalculated Sharing Rules
```

_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/recalculate.ts)_
_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/recalculate.ts)_

## `sfdx texei:sharingcalc:resume [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -416,7 +419,7 @@ EXAMPLE
Sharing calculations resumed
```

_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/resume.ts)_
_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/resume.ts)_

## `sfdx texei:sharingcalc:suspend [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -447,7 +450,7 @@ EXAMPLE
Sharing calculations suspended
```

_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/suspend.ts)_
_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/suspend.ts)_

## `sfdx texei:skinnyprofile:retrieve [-t <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -477,7 +480,7 @@ EXAMPLE
$ texei:skinnyprofile:retrieve -u MyScratchOrg
```

_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/skinnyprofile/retrieve.ts)_
_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/skinnyprofile/retrieve.ts)_

## `sfdx texei:source:customlabel:replace -l <string> -v <string> [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -501,7 +504,7 @@ EXAMPLE
$ texei:source:customlabel:replace --label GreatSalesforceBlog --value https://blog.texei.com
```

_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/source/customlabel/replace.ts)_
_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/source/customlabel/replace.ts)_

## `sfdx texei:source:layouts:cleanorg [-p <string>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -534,7 +537,7 @@ EXAMPLES
$ texei:source:layouts:cleanorg --targetusername myScratchOrg --targetdevhubusername myDevHub
```

_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/source/layouts/cleanorg.ts)_
_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/source/layouts/cleanorg.ts)_

## `sfdx texei:user:update [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -567,5 +570,5 @@ EXAMPLES
sfdx texei:user:update --values "LanguageLocaleKey=en_US UserPermissionsMarketingUser=true" --json
```

_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/user/update.ts)_
_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/user/update.ts)_
<!-- commandsstop -->
3 changes: 2 additions & 1 deletion messages/contractstatus-value-add.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"commandDescription": "add a value to Contract Status picklist",
"labelFlagDescription": "label of the Contract Status value to add",
"apiNameFlagDescription": "API Name of the Contract Status value to add"
"apiNameFlagDescription": "API Name of the Contract Status value to add",
"statusCategoryFlagDescription": "Status Category of the Contract Status value to add"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "texei-sfdx-plugin",
"description": "Texeï's plugin for sfdx",
"version": "1.9.2",
"version": "1.9.3",
"author": "Texeï",
"bugs": "https://github.com/https://github.com/texei/texei-sfdx-plugin/issues",
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/texei/contractstatus/value/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default class Add extends SfdxCommand {

protected static flagsConfig = {
label: flags.string({char: 'l', description: messages.getMessage('labelFlagDescription'), required: true}),
apiname: flags.string({char: 'a', description: messages.getMessage('apiNameFlagDescription'), required: true})
apiname: flags.string({char: 'a', description: messages.getMessage('apiNameFlagDescription'), required: true}),
statuscategory: flags.string({char: 's', description: messages.getMessage('statusCategoryFlagDescription'), options: ['Draft','Activated','InApprovalProcess'], default: 'Draft', required: false})
};

// Comment this out if your command does not require an org username
Expand All @@ -37,7 +38,7 @@ export default class Add extends SfdxCommand {
this.ux.startSpinner(`Adding ContractStatus value (${this.flags.label}/${this.flags.apiname})`, null, { stdout: true });

const svsh = new StandardValueSetHelper(this.org.getConnection(), 'ContractStatus');
await svsh.addValue(this.flags.label, this.flags.apiname);
await svsh.addValue(this.flags.label, this.flags.apiname, this.flags.statuscategory);
await svsh.close();

this.ux.stopSpinner('Done.');
Expand Down
13 changes: 5 additions & 8 deletions src/shared/standardValueSetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ const standardValueSetPaths = new Map([
['ContractStatus', '/_ui/common/config/field/StandardFieldAttributes/d?id=Status&type=Contract']
]);

// TODO: look how to handle languages
/*
const contractStatusCategory = new Map([
['D', 'Draft'],
['A', 'Activated'],
['P', 'In Approval Process']
['Draft', 'D'],
['Activated', 'A'],
['InApprovalProcess', 'P']
]);
*/

export class StandardValueSetHelper {

Expand Down Expand Up @@ -53,7 +50,7 @@ export class StandardValueSetHelper {
}
}

public async addValue(label: string, apiName: string): Promise<string> {
public async addValue(label: string, apiName: string, statusCategory: string): Promise<string> {

if (!this.browser) {
await this.init();
Expand Down Expand Up @@ -93,7 +90,7 @@ export class StandardValueSetHelper {
// TODO: Handle other Category than Draft
await this.page.waitForSelector('tbody #p5');
await this.page.click('tbody #p5');
await this.page.select('tbody #p5', 'D');
await this.page.select('tbody #p5', contractStatusCategory.get(statusCategory));
}

// Click Save
Expand Down

0 comments on commit 5c34266

Please sign in to comment.