diff --git a/src/commands/generate/cmdt/record.ts b/src/commands/generate/cmdt/record.ts index ba095109..83cad5a1 100644 --- a/src/commands/generate/cmdt/record.ts +++ b/src/commands/generate/cmdt/record.ts @@ -30,6 +30,7 @@ export interface CmdtRecordCreateResponse { fileData: CustomField[]; } export default class Create extends SfCommand { + public static readonly strict = false; public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly requiresProject = true; diff --git a/test/nuts/local/createRecord.nut.ts b/test/nuts/local/createRecord.nut.ts index f5183b75..43873e4b 100644 --- a/test/nuts/local/createRecord.nut.ts +++ b/test/nuts/local/createRecord.nut.ts @@ -202,5 +202,41 @@ describe('cmdt record create', () => { expect(xml.includes('Checkbox')).to.be.true; expect(xml.includes('false')).to.be.true; }); + it('should create records without optional flags and field values', async () => { + const testDir = 'outputTestDir'; + const fieldDirPath = path.join(testDir, 'Output_Test__mdt', 'fields'); + const filePath = path.join(projDir, fieldDirPath, 'Check__c.field-meta.xml'); + const recordFilePath = path.join( + projDir, + testDir, + 'customMetadata', + 'Output_Test.Output_Test_Record.md-meta.xml' + ); + const outputDir = path.join(testDir, 'Output_Test__mdt'); + execCmd(`force:cmdt:create --typename Output_Test --outputdir ${testDir}`, { ensureExitCode: 0 }); + execCmd(`force:cmdt:field:create --fieldname Check --fieldtype Checkbox --outputdir ${outputDir}`, { + ensureExitCode: 0, + }); + execCmd( + `force:cmdt:record:create -t Output_Test -n Output_Test_Record -i ${testDir} -d ${path.join( + testDir, + 'customMetadata' + )} Check__c=true`, + { ensureExitCode: 0 } + ); + expect(fs.existsSync(path.join(projDir, fieldDirPath))).to.be.true; + expect(fs.existsSync(filePath)).to.be.true; + + const xml = await fs.promises.readFile(filePath, { encoding: 'utf-8' }); + expect(xml.includes('Check__c')).to.be.true; + expect(xml.includes('DeveloperControlled')).to.be.true; + expect(xml.includes('')).to.be.true; + expect(xml.includes('Checkbox')).to.be.true; + expect(xml.includes('false')).to.be.true; + const recordXml = await fs.promises.readFile(recordFilePath, { encoding: 'utf-8' }); + expect(recordXml.includes('')).to.be.true; + expect(recordXml.includes('Check__c')).to.be.true; + expect(/true<\/value>/.test(recordXml)).to.be.true; + }); }); });