Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Fix recordType query in metadataRetriever (#501)
Browse files Browse the repository at this point in the history
* Fix Issue #500

* Bump patch version
  • Loading branch information
aly76 authored Apr 8, 2021
1 parent 627773d commit 5b7671d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion oclif.manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.8.6",
"version": "2.8.7",
"commands": {
"sfpowerkit:auth:login": {
"id": "sfpowerkit:auth:login",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sfpowerkit",
"version": "2.8.6",
"version": "2.8.7",
"author": {
"name": "DXatScale",
"email": "dxatscale@accenture.com"
Expand Down
19 changes: 16 additions & 3 deletions src/impl/metadata/retriever/metadataRetriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,21 @@ export default class MetadataRetriever {
try {
SFPowerkit.log(`Fetching RecordTypes`, LoggerLevel.TRACE);

let query = `SELECT Name, DeveloperName, SobjectType, NameSpacePrefix, IsPersonType FROM RecordType`;
let queryUtil = new QueryExecutor(this._conn);
recordTypes = await queryUtil.executeQuery(query, false);

let isPersonAccountFieldDefinitionQuery = `SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName='Account' AND QualifiedApiName='IsPersonAccount'`;
let isPersonAccountFieldDefinitionRecords = await queryUtil.executeQuery(
isPersonAccountFieldDefinitionQuery,
true
);

let recordTypeQuery: string;
if (isPersonAccountFieldDefinitionRecords.length > 0)
recordTypeQuery = `SELECT Name, DeveloperName, SobjectType, NameSpacePrefix, IsPersonType FROM RecordType`;
else
recordTypeQuery = `SELECT Name, DeveloperName, SobjectType, NameSpacePrefix FROM RecordType`;

recordTypes = await queryUtil.executeQuery(recordTypeQuery, false);

recordTypes = recordTypes.map((recordType) => {
let namespace = "";
Expand All @@ -237,7 +249,8 @@ export default class MetadataRetriever {
return rtObj;
});
} catch (error) {
SFPowerkit.log(`Error fetching record types...`, LoggerLevel.TRACE);
SFPowerkit.log(`Error fetching record types...`, LoggerLevel.DEBUG);
SFPowerkit.log(error.message, LoggerLevel.DEBUG);
}
return recordTypes;
}
Expand Down

0 comments on commit 5b7671d

Please sign in to comment.