Skip to content

Commit d635111

Browse files
committed
feat(salesforcecli): adding sort by field, so we will get the correct version migrated
1 parent 6723dfc commit d635111

File tree

3 files changed

+238
-158
lines changed

3 files changed

+238
-158
lines changed

src/migration/flexcard.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable */
22
import { AnyJson } from '@salesforce/ts-types';
33
import CardMappings from '../mappings/VlocityCard';
4-
import { DebugTimer, QueryTools } from '../utils';
4+
import { DebugTimer, QueryTools, SortDirection } from '../utils';
55
import { NetUtils } from '../utils/net';
66
import { BaseMigrationTool } from './base';
77
import { MigrationResult, MigrationTool, ObjectMapping, UploadRecordResult } from './interfaces';
@@ -92,20 +92,32 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
9292
// Query all cards that are active
9393
private async getAllActiveCards(): Promise<AnyJson[]> {
9494
DebugTimer.getInstance().lap('Query Vlocity Cards');
95-
// const filterStr: string = ` Where ${this.namespacePrefix}Active__c = true`
9695
const filters = new Map<string, any>();
97-
if (!this.allVersions) {
98-
filters.set(this.namespacePrefix + 'Active__c', true);
99-
}
10096
filters.set(this.namespacePrefix + 'CardType__c', 'flex');
10197

102-
return await QueryTools.queryWithFilter(
103-
this.connection,
104-
this.namespace,
105-
CardMigrationTool.VLOCITYCARD_NAME,
106-
this.getCardFields(),
107-
filters
108-
);
98+
if (this.allVersions) {
99+
const sortFields = [
100+
{ field: 'Name', direction: SortDirection.ASC },
101+
{ field: this.namespacePrefix + 'Version__c', direction: SortDirection.ASC },
102+
];
103+
return await QueryTools.queryWithFilterAndSort(
104+
this.connection,
105+
this.namespace,
106+
CardMigrationTool.VLOCITYCARD_NAME,
107+
this.getCardFields(),
108+
filters,
109+
sortFields
110+
);
111+
} else {
112+
filters.set(this.namespacePrefix + 'Active__c', true);
113+
return await QueryTools.queryWithFilter(
114+
this.connection,
115+
this.namespace,
116+
CardMigrationTool.VLOCITYCARD_NAME,
117+
this.getCardFields(),
118+
filters
119+
);
120+
}
109121
}
110122

111123
// Upload All the VlocityCard__c records to OmniUiCard

src/migration/omniscript.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,23 +375,37 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
375375
DebugTimer.getInstance().lap('Query OmniScripts');
376376
this.logger.info('allVersions : ' + this.allVersions);
377377
const filters = new Map<string, any>();
378-
if (!this.allVersions) {
379-
filters.set(this.namespacePrefix + 'IsActive__c', true);
380-
}
381378

382379
if (this.exportType === OmniScriptExportType.IP) {
383380
filters.set(this.namespacePrefix + 'IsProcedure__c', true);
384381
} else if (this.exportType === OmniScriptExportType.OS) {
385382
filters.set(this.namespacePrefix + 'IsProcedure__c', false);
386383
}
387384

388-
return await QueryTools.queryWithFilter(
389-
this.connection,
390-
this.namespace,
391-
OmniScriptMigrationTool.OMNISCRIPT_NAME,
392-
this.getOmniScriptFields(),
393-
filters
394-
);
385+
if (this.allVersions) {
386+
const sortFields = [
387+
{ field: this.namespacePrefix + 'Type__c', direction: SortDirection.ASC },
388+
{ field: this.namespacePrefix + 'SubType__c', direction: SortDirection.ASC },
389+
{ field: this.namespacePrefix + 'Version__c', direction: SortDirection.ASC },
390+
];
391+
return await QueryTools.queryWithFilterAndSort(
392+
this.connection,
393+
this.namespace,
394+
OmniScriptMigrationTool.OMNISCRIPT_NAME,
395+
this.getOmniScriptFields(),
396+
filters,
397+
sortFields
398+
);
399+
} else {
400+
filters.set(this.namespacePrefix + 'IsActive__c', true);
401+
return await QueryTools.queryWithFilter(
402+
this.connection,
403+
this.namespace,
404+
OmniScriptMigrationTool.OMNISCRIPT_NAME,
405+
this.getOmniScriptFields(),
406+
filters
407+
);
408+
}
395409
}
396410

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

0 commit comments

Comments
 (0)