Skip to content

Commit

Permalink
feat(salesforcecli): adding sort by field, so we will get the correct…
Browse files Browse the repository at this point in the history
… version migrated
  • Loading branch information
Johan Schonning committed Nov 6, 2023
1 parent efba231 commit 8c6b85c
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 158 deletions.
36 changes: 24 additions & 12 deletions src/migration/flexcard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
import { AnyJson } from '@salesforce/ts-types';
import CardMappings from '../mappings/VlocityCard';
import { DebugTimer, QueryTools } from '../utils';
import { DebugTimer, QueryTools, SortDirection } from '../utils';
import { NetUtils } from '../utils/net';
import { BaseMigrationTool } from './base';
import { MigrationResult, MigrationTool, ObjectMapping, UploadRecordResult } from './interfaces';
Expand Down Expand Up @@ -92,20 +92,32 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
// Query all cards that are active
private async getAllActiveCards(): Promise<AnyJson[]> {
DebugTimer.getInstance().lap('Query Vlocity Cards');
// const filterStr: string = ` Where ${this.namespacePrefix}Active__c = true`
const filters = new Map<string, any>();
if (!this.allVersions) {
filters.set(this.namespacePrefix + 'Active__c', true);
}
filters.set(this.namespacePrefix + 'CardType__c', 'flex');

return await QueryTools.queryWithFilter(
this.connection,
this.namespace,
CardMigrationTool.VLOCITYCARD_NAME,
this.getCardFields(),
filters
);
if (this.allVersions) {
const sortFields = [
{ field: 'Name', direction: SortDirection.ASC },
{ field: this.namespacePrefix + 'Version__c', direction: SortDirection.ASC },
];
return await QueryTools.queryWithFilterAndSort(
this.connection,
this.namespace,
CardMigrationTool.VLOCITYCARD_NAME,
this.getCardFields(),
filters,
sortFields
);
} else {
filters.set(this.namespacePrefix + 'Active__c', true);
return await QueryTools.queryWithFilter(
this.connection,
this.namespace,
CardMigrationTool.VLOCITYCARD_NAME,
this.getCardFields(),
filters
);
}
}

// Upload All the VlocityCard__c records to OmniUiCard
Expand Down
34 changes: 24 additions & 10 deletions src/migration/omniscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,23 +375,37 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
DebugTimer.getInstance().lap('Query OmniScripts');
this.logger.info('allVersions : ' + this.allVersions);
const filters = new Map<string, any>();
if (!this.allVersions) {
filters.set(this.namespacePrefix + 'IsActive__c', true);
}

if (this.exportType === OmniScriptExportType.IP) {
filters.set(this.namespacePrefix + 'IsProcedure__c', true);
} else if (this.exportType === OmniScriptExportType.OS) {
filters.set(this.namespacePrefix + 'IsProcedure__c', false);
}

return await QueryTools.queryWithFilter(
this.connection,
this.namespace,
OmniScriptMigrationTool.OMNISCRIPT_NAME,
this.getOmniScriptFields(),
filters
);
if (this.allVersions) {
const sortFields = [
{ field: this.namespacePrefix + 'Type__c', direction: SortDirection.ASC },
{ field: this.namespacePrefix + 'SubType__c', direction: SortDirection.ASC },
{ field: this.namespacePrefix + 'Version__c', direction: SortDirection.ASC },
];
return await QueryTools.queryWithFilterAndSort(
this.connection,
this.namespace,
OmniScriptMigrationTool.OMNISCRIPT_NAME,
this.getOmniScriptFields(),
filters,
sortFields
);
} else {
filters.set(this.namespacePrefix + 'IsActive__c', true);
return await QueryTools.queryWithFilter(
this.connection,
this.namespace,
OmniScriptMigrationTool.OMNISCRIPT_NAME,
this.getOmniScriptFields(),
filters
);
}
}

// Get All Elements w.r.t OmniScript__c i.e Elements tagged to passed in IP/OS
Expand Down
Loading

0 comments on commit 8c6b85c

Please sign in to comment.