Skip to content

Commit 37dfa87

Browse files
Merge pull request #429 from sf-aastha-paruthi/u/aparuthi/flexcardupdates
@W-19821865 Flexcard Name update for standard model
2 parents a109391 + 11c1f54 commit 37dfa87

File tree

7 files changed

+44
-95
lines changed

7 files changed

+44
-95
lines changed

messages/assess.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@
197197
"dmNameUpdateFailed": "DM reference %s can’t be updated",
198198
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again",
199199
"assessmentSuccessfulMessage": "Migration assessment for org %s is complete and reports are ready for review in the folder %s",
200-
"needManualInterventionAsSpecialCharsInChildFlexcardName": "Child Flexcards with special characters in their names must be manually migrated.",
201-
"needManualInterventionAsSpecialCharsInFlexcardName": "This Flexcard contains special characters in its name. It must be manually migrated.",
202200
"errorCheckingOmniStudioMetadata": "We couldn't check whether the Omnistudio Metadata is enabled: %s. Try again later.",
203201
"omniStudioSettingsMetadataAlreadyEnabled": "The Omnistudio Metadata setting is already enabled with standard data model. No need for migration."
204202
}

messages/migrate.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@
247247
"generatedCustomLabelAssessmentReportPage": "Generated custom label assessment report page %s of %s with %s labels",
248248
"varDeclarationUpdated": "Variable initialization has been updated for target name",
249249
"migrationSuccessfulMessage": "Migration process for org %s is complete and reports are ready for review in the folder %s",
250-
"needManualInterventionAsSpecialCharsInChildFlexcardName": "Need manual intervention as child flexcards have special characters in their name",
251-
"needManualInterventionAsSpecialCharsInFlexcardName": "Need manual intervention as flexcard has special characters in name",
252250
"metadataTablesAlreadyClean": "OmniStudio metadata tables are empty",
253251
"startingMetadataCleanup": "Initiated cleanup process for Omnistudio metadata tables.",
254252
"failedToCleanTables": "Table cleanup failed: %s",

src/migration/dataraptor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
386386
const drItems = dataRaptorItemsMap.get(drName);
387387
if (drItems) {
388388
for (const drItem of drItems) {
389-
// Logger.log(dataRaptor[this.namespacePrefix + 'Formula__c']);
390389
const formula = drItem[this.getItemFieldKey('Formula__c')];
391390
if (formula) {
392391
try {

src/migration/flexcard.ts

Lines changed: 32 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
8989

9090
// Perform Records Migration from VlocityCard__c to OmniUiCard
9191
async migrate(): Promise<MigrationResult[]> {
92-
// Get All the Active VlocityCard__c records
93-
const allCards = await this.getAllActiveCards();
92+
const allCards = await this.getAllCards();
9493

9594
Logger.log(this.messages.getMessage('foundFlexCardsToMigrate', [allCards.length]));
9695

@@ -156,7 +155,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
156155
public async assess(): Promise<FlexCardAssessmentInfo[]> {
157156
try {
158157
Logger.log(this.messages.getMessage('startingFlexCardAssessment'));
159-
const flexCards = await this.getAllActiveCards();
158+
const flexCards = await this.getAllCards();
160159
Logger.log(this.messages.getMessage('foundFlexCardsToAssess', [flexCards.length]));
161160

162161
const flexCardsAssessmentInfos = await this.processCardComponents(flexCards);
@@ -234,20 +233,10 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
234233
'Ready for migration';
235234
flexCardAssessmentInfo.name = this.allVersions ? `${cleanedName}_${version}` : cleanedName;
236235
if (cleanedName !== originalName) {
237-
if (!this.IS_STANDARD_DATA_MODEL) {
238-
flexCardAssessmentInfo.warnings.push(
239-
this.messages.getMessage('cardNameChangeMessage', [originalName, cleanedName])
240-
);
241-
assessmentStatus = getUpdatedAssessmentStatus(assessmentStatus, 'Warnings');
242-
} else {
243-
flexCardAssessmentInfo.warnings.push(
244-
this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')
245-
);
246-
flexCardAssessmentInfo.errors.push(
247-
this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')
248-
);
249-
assessmentStatus = 'Needs Manual Intervention';
250-
}
236+
flexCardAssessmentInfo.warnings.push(
237+
this.messages.getMessage('cardNameChangeMessage', [originalName, cleanedName])
238+
);
239+
assessmentStatus = getUpdatedAssessmentStatus(assessmentStatus, 'Warnings');
251240
}
252241

253242
// Check for duplicate names
@@ -404,23 +393,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
404393

405394
// Add warning if child card name will change
406395
if (childCardName !== cleanedChildCardName) {
407-
if (!this.IS_STANDARD_DATA_MODEL) {
408-
flexCardAssessmentInfo.warnings.push(
409-
this.messages.getMessage('cardNameChangeMessage', [childCardName, cleanedChildCardName])
410-
);
411-
flexCardAssessmentInfo.migrationStatus = getUpdatedAssessmentStatus(
412-
flexCardAssessmentInfo.migrationStatus,
413-
'Warnings'
414-
);
415-
} else {
416-
flexCardAssessmentInfo.warnings.push(
417-
this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')
418-
);
419-
flexCardAssessmentInfo.errors.push(
420-
this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')
421-
);
422-
flexCardAssessmentInfo.migrationStatus = 'Needs Manual Intervention';
423-
}
396+
flexCardAssessmentInfo.warnings.push(
397+
this.messages.getMessage('cardNameChangeMessage', [childCardName, cleanedChildCardName])
398+
);
399+
flexCardAssessmentInfo.migrationStatus = getUpdatedAssessmentStatus(
400+
flexCardAssessmentInfo.migrationStatus,
401+
'Warnings'
402+
);
424403
}
425404
}
426405
} catch (err) {
@@ -694,8 +673,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
694673
}
695674
}
696675

697-
// Query all cards that are active
698-
private async getAllActiveCards(): Promise<AnyJson[]> {
676+
private async getAllCards(): Promise<AnyJson[]> {
699677
//DebugTimer.getInstance().lap('Query Vlocity Cards');
700678
const filters = new Map<string, any>();
701679

@@ -740,7 +718,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
740718
}
741719
}
742720

743-
// Upload All the VlocityCard__c records to OmniUiCard
721+
// Upload All the VlocityCard__c records to OmniUiCard for custom model and update references for standard
744722
private async uploadAllCards(
745723
cards: any[],
746724
progressBar: ReturnType<typeof createProgressBar>
@@ -789,42 +767,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
789767
}
790768
}
791769

792-
const isChildCardUpdated: boolean = this.updateChildCards(card);
793-
794-
if (this.IS_STANDARD_DATA_MODEL && isChildCardUpdated) {
795-
originalRecords.set(recordId, card);
796-
797-
cardsUploadInfo.set(recordId, {
798-
referenceId: recordId,
799-
hasErrors: true,
800-
success: false,
801-
errors: [this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')],
802-
warnings: [],
803-
});
804-
805-
return;
806-
}
770+
this.updateChildCards(card);
807771
}
808772

809773
// Perform the transformation
810774
const invalidIpNames = new Map<string, string>();
811775
const transformedCard = this.mapVlocityCardRecord(card, cardsUploadInfo, invalidIpNames); // This only has the card structure, card definition is not there
812776

813-
if (this.IS_STANDARD_DATA_MODEL) {
814-
if (transformedCard['Name'] != card['Name']) {
815-
originalRecords.set(recordId, card);
816-
817-
cardsUploadInfo.set(recordId, {
818-
referenceId: recordId,
819-
hasErrors: true,
820-
success: false,
821-
errors: [this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')],
822-
warnings: [],
823-
});
824-
return;
825-
}
826-
}
827-
828777
// Verify duplicated names
829778
let transformedCardName: string;
830779
if (this.allVersions) {
@@ -1064,11 +1013,9 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10641013
return childs;
10651014
}
10661015

1067-
private updateChildCards(card: AnyJson): boolean {
1016+
private updateChildCards(card: AnyJson): void {
10681017
const definition = JSON.parse(card[this.getFieldKey('Definition__c')]);
1069-
if (!definition) return false;
1070-
1071-
let hasNameChanges = false;
1018+
if (!definition) return;
10721019

10731020
for (let state of definition.states || []) {
10741021
if (state.childCards && Array.isArray(state.childCards)) {
@@ -1078,14 +1025,12 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10781025
// Check if any child card name was changed
10791026
for (let i = 0; i < originalChildCards.length; i++) {
10801027
if (originalChildCards[i] !== state.childCards[i]) {
1081-
hasNameChanges = true;
10821028
}
10831029
}
10841030
}
10851031
}
10861032

10871033
card[this.getFieldKey('Definition__c')] = JSON.stringify(definition);
1088-
return hasNameChanges;
10891034
}
10901035

10911036
// Maps an indivitdual VlocityCard__c record to an OmniUiCard record.
@@ -1138,6 +1083,18 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
11381083
mappedObject[CardMappings.Author__c] = this.cleanName(mappedObject[CardMappings.Author__c]);
11391084
mappedObject[CardMappings.Active__c] = false;
11401085

1086+
if (this.IS_STANDARD_DATA_MODEL) {
1087+
if (mappedObject['OmniUiCardKey']) {
1088+
mappedObject['OmniUiCardKey'] =
1089+
mappedObject['Name'] +
1090+
'/' +
1091+
mappedObject[CardMappings.Author__c] +
1092+
'/' +
1093+
mappedObject[CardMappings.Version__c] +
1094+
'.0';
1095+
}
1096+
}
1097+
11411098
// Update the datasource
11421099
const datasource = JSON.parse(mappedObject[CardMappings.Datasource__c] || '{}');
11431100
if (datasource.dataSource) {
@@ -1159,7 +1116,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
11591116
mappedObject[CardMappings.Datasource__c] = JSON.stringify(datasource);
11601117
}
11611118

1162-
const isCardActive: boolean = cardRecord[`${this.namespacePrefix}Active__c`];
1119+
const isCardActive: boolean = cardRecord[this.getFieldKey('Active__c')];
11631120
this.ensureCommunityTargets(mappedObject, isCardActive);
11641121

11651122
// Update all dependencies comprehensively
@@ -1671,6 +1628,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
16711628
/**
16721629
* Ensures that the FlexCard Definition includes required Lightning Community targets
16731630
* Adds "lightningCommunity__Page" and "lightningCommunity__Default" if missing
1631+
* This is needed as vlocity wrapper can have flexcard which is unpublished but omniwapper needs published card
16741632
*/
16751633
private ensureCommunityTargets(mappedObject: any, isCardActive: boolean): void {
16761634
if (!isCardActive) {

src/migration/omniscript.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,6 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
12961296
? filters.set('OmniProcessId', recordId)
12971297
: filters.set(this.namespacePrefix + 'OmniScriptId__c', recordId);
12981298

1299-
// const queryFilterStr = ` Where ${this.namespacePrefix}OmniScriptId__c = '${omniScriptData.keys().next().value}'`;
13001299
return await QueryTools.queryWithFilter(
13011300
this.connection,
13021301
this.getQueryNamespace(),
@@ -1314,7 +1313,6 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
13141313
? filters.set('OmniProcessId', recordId)
13151314
: filters.set(this.namespacePrefix + 'OmniScriptId__c', recordId);
13161315

1317-
// const queryFilterStr = ` Where ${this.namespacePrefix}OmniScriptId__c = '${omniScriptData.keys().next().value}'`;
13181316
return await QueryTools.queryWithFilter(
13191317
this.connection,
13201318
this.getQueryNamespace(),
@@ -1540,10 +1538,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
15401538

15411539
if (
15421540
cleanFieldName === 'ParentElementId__c' &&
1543-
parentElementUploadResponse.has(elementRecord[`${this.namespacePrefix}ParentElementId__c`])
1541+
parentElementUploadResponse.has(elementRecord[this.getElementFieldKey('ParentElementId__c')])
15441542
) {
15451543
mappedObject[ElementMappings[cleanFieldName]] = parentElementUploadResponse.get(
1546-
elementRecord[`${this.namespacePrefix}ParentElementId__c`]
1544+
elementRecord[this.getElementFieldKey('ParentElementId__c')]
15471545
).id;
15481546
}
15491547
}

test/migration/flexcard-standard-datamodel.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ describe('FlexCard Standard Data Model (Metadata API Disabled) - Assessment and
3030
mockConnection = {};
3131
mockMessages = {
3232
getMessage: (key: string, args?: string[]) => {
33-
if (key === 'needManualInterventionAsSpecialCharsInFlexcardName') {
34-
return 'FlexCard name contains special characters and cannot be auto-migrated';
35-
}
3633
if (key === 'cardNameChangeMessage') {
3734
return `The card name '${args?.[0]}' will be changed to '${args?.[1]}'`;
3835
}
@@ -117,9 +114,10 @@ describe('FlexCard Standard Data Model (Metadata API Disabled) - Assessment and
117114
expect(result.name).to.equal('CustomerProfileCard');
118115
expect(result.oldName).to.equal('Customer-Profile@Card!');
119116

120-
// Should add warning for manual intervention due to special characters
121-
expect(result.warnings).to.include('FlexCard name contains special characters and cannot be auto-migrated');
122-
expect(result.migrationStatus).to.equal('Needs Manual Intervention');
117+
// Should add warning about name change (name updates are now allowed, so status is Warnings not Manual Intervention)
118+
expect(result.warnings).to.have.length.greaterThan(0);
119+
expect(result.warnings[0]).to.include("will be changed to 'CustomerProfileCard'");
120+
expect(result.migrationStatus).to.equal('Warnings');
123121

124122
// Dependencies should still be detected for assessment
125123
expect(result.dependenciesDR).to.have.length.greaterThan(0);
@@ -193,7 +191,7 @@ describe('FlexCard Standard Data Model (Metadata API Disabled) - Assessment and
193191
it('should map OmniUiCard fields correctly for Standard Data Model', () => {
194192
const mockCardRecord = {
195193
Id: 'fc1',
196-
Name: 'TestCard',
194+
Name: 'TestCard!@#',
197195
DataSourceConfig: JSON.stringify({
198196
type: 'DataRaptor',
199197
value: { bundle: 'TestBundle' },
@@ -218,7 +216,7 @@ describe('FlexCard Standard Data Model (Metadata API Disabled) - Assessment and
218216
expect(result.AuthorName).to.equal('TestAuthor');
219217
expect(result.VersionNumber).to.equal(2);
220218
expect(result.OmniUiCardType).to.equal('Parent');
221-
expect(result.OmniUiCardKey).to.equal('test-card-key');
219+
expect(result.OmniUiCardKey).to.equal('TestCard/TestAuthor/2.0');
222220
});
223221

224222
it('should process DataRaptor data source and preserve registry mapping functionality', () => {
@@ -612,7 +610,7 @@ describe('FlexCard Standard Data Model (Metadata API Disabled) - Assessment and
612610
expect(result.StylingConfiguration).to.equal('style-config');
613611
expect(result.OmniUiCardType).to.equal('Parent');
614612
expect(result.VersionNumber).to.equal(1);
615-
expect(result.OmniUiCardKey).to.equal('card-key');
613+
expect(result.OmniUiCardKey).to.equal('TestCard/TestAuthor/1.0');
616614
});
617615
});
618616
});

test/migration/flexcard/flexcard-angular-dependencies.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ describe('FlexCard Angular Dependency Validation', () => {
257257
}),
258258
};
259259

260-
// Mock getAllActiveCards method
261-
(cardTool as any).getAllActiveCards = () => Promise.resolve([mockFlexCardWithAngular, mockFlexCardWithLWC]);
260+
// Mock getAllCards method
261+
(cardTool as any).getAllCards = () => Promise.resolve([mockFlexCardWithAngular, mockFlexCardWithLWC]);
262262

263263
// Mock uploadAllCards method to track which cards are processed
264264
const processedCards: any[] = [];
@@ -293,7 +293,7 @@ describe('FlexCard Angular Dependency Validation', () => {
293293
}),
294294
};
295295

296-
(cardTool as any).getAllActiveCards = () => Promise.resolve([mockFlexCardWithAngular]);
296+
(cardTool as any).getAllCards = () => Promise.resolve([mockFlexCardWithAngular]);
297297
(cardTool as any).uploadAllCards = () => Promise.resolve(new Map());
298298

299299
const result = await cardTool.migrate();

0 commit comments

Comments
 (0)