Skip to content

Commit 853fe02

Browse files
authored
Merge pull request #385 from mdmehran-qureshi/fix/ip-type-subtype-validation-and-dm-start-with-number
Fix: DM Name start with number and IP having empty or '_' type/subtype
2 parents 9b2d594 + 6156087 commit 853fe02

File tree

4 files changed

+157
-19
lines changed

4 files changed

+157
-19
lines changed

messages/assess.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@
184184
"nameMappingUndefined": "Undefined name mapping found",
185185
"experienceSiteException": "We’ve encountered an exception while processing Experience Cloud sites.",
186186
"reservedKeysFoundInPropertySet": "Reserved keys found in any of output response transformation fields: %s.",
187+
"integrationProcedureMissingMandatoryField": "Integration Procedure %s is missing mandatory %s field",
188+
"dataMapperMigrationFailed": "DataMapper migration failed for: %s",
189+
"dataMapperNameStartsWithNumber": "DataMapper name '%s' starts with a number which causes migration issues. Proposed new name: %s",
190+
"dataMapperNamePrefixedWithDM": "DataMapper name '%s' starts with a number. Prefixing with 'DM_' to create valid name: %s",
191+
"integrationProcedureTypeEmptyAfterCleaning": "Integration Procedure Type '%s' becomes empty after name cleaning. Please provide a valid Type value.",
192+
"integrationProcedureSubtypeEmptyAfterCleaning": "Integration Procedure SubType '%s' becomes empty after name cleaning. Please provide a valid SubType value.",
187193
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again",
188194
"apexFileAlreadyHasCallMethod": "File %s already has call method, thus keeping the existing call method intact",
189195
"errorFetchingCustomLabels": "Error fetching custom labels: %s",

messages/migrate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@
216216
"skipFlexcardAngularOmniScriptDependencyWarning": "Skipping FlexCard %s due to Angular Omniscript dependencies",
217217
"flexCardMigrationProcessingMessage": "Processing %s FlexCards for migration (%s skipped due to Angular dependencies)",
218218
"noMetadataToDeploy": "No metadata to deploy",
219+
"missingMandatoryField": "Missing mandatory field: %s for %s",
220+
"dataMapperMigrationFailed": "DataMapper migration failed for: %s",
221+
"dataMapperNameStartsWithNumber": "DataMapper name '%s' starts with a number which causes migration issues. Proposed new name: %s",
222+
"dataMapperNamePrefixedWithDM": "DataMapper name '%s' starts with a number. Prefixing with 'DM_' to create valid name: %s",
223+
"integrationProcedureTypeEmptyAfterCleaning": "Integration Procedure Type '%s' becomes empty after name cleaning. Please provide a valid Type value.",
224+
"integrationProcedureSubtypeEmptyAfterCleaning": "Integration Procedure SubType '%s' becomes empty after name cleaning. Please provide a valid SubType value.",
219225
"manifestDeployementStarted": "Manifest deployment started with ID: %s",
220226
"migrationConsentMessage": "Make sure that all records listed in the Assessment Status column in the Assessment Report are marked as Green before proceeding with the migration. Do you want to proceed? Yes or No?",
221227
"truncationFailed": "Truncation failed for %s: %s",

src/migration/dataraptor.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,51 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
162162
originalDrRecords.set(recordId, dr);
163163
continue;
164164
}
165+
166+
if (transformedDataRaptor['Name'] && /^[0-9]/.test(transformedDataRaptor['Name'])) {
167+
this.setRecordErrors(dr, this.messages.getMessage('dataMapperNameStartsWithNumber', [transformedDataRaptor['Name'], 'DM' + transformedDataRaptor['Name']]));
168+
originalDrRecords.set(recordId, dr);
169+
continue;
170+
}
171+
165172
duplicatedNames.add(transformedDataRaptor['Name']);
166173

167174
// Create a map of the original records
168175
originalDrRecords.set(recordId, dr);
169176

170177
// Save the data raptors
171178
// const drUploadResponse = await this.uploadTransformedData(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME, { mappedRecords, originalRecords });
172-
const drUploadResponse = await NetUtils.createOne(
179+
let drUploadResponse = await NetUtils.createOne(
173180
this.connection,
174181
DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME,
175182
recordId,
176183
transformedDataRaptor
177184
);
178185

186+
// Always add the response to track success/failure
179187
if (drUploadResponse && drUploadResponse.success === true) {
180188
const items = await this.getItemsForDataRaptor(dataRaptorItemsData, name, drUploadResponse.id);
181189

182190
drUploadResponse.newName = transformedDataRaptor[DRBundleMappings.Name];
183191

184192
// Move the items
185193
await this.uploadTransformedData(DataRaptorMigrationTool.OMNIDATATRANSFORMITEM_NAME, items);
186-
187-
drUploadInfo.set(recordId, drUploadResponse);
194+
} else {
195+
// Handle failed migration - add error information
196+
if (!drUploadResponse) {
197+
drUploadResponse = {
198+
referenceId: recordId,
199+
id: '',
200+
success: false,
201+
hasErrors: true,
202+
errors: [this.messages.getMessage('dataMapperMigrationFailed', [name])],
203+
warnings: [],
204+
newName: '',
205+
};
206+
}
188207
}
208+
209+
drUploadInfo.set(recordId, drUploadResponse);
189210
}
190211
progressBar.stop();
191212

@@ -297,6 +318,13 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
297318
);
298319
assessmentStatus = 'Warnings';
299320
}
321+
// Check if name starts with a number (which can cause migration issues)
322+
if (drName && /^[0-9]/.test(drName)) {
323+
const proposedName = 'DM' + this.cleanName(drName);
324+
warnings.push(this.messages.getMessage('dataMapperNameStartsWithNumber', [drName, proposedName]));
325+
assessmentStatus = 'Needs Manual Intervention';
326+
}
327+
300328
if (existingDataRaptorNames.has(existingDRNameVal.cleanName())) {
301329
warnings.push(this.messages.getMessage('duplicatedName') + ' ' + existingDRNameVal.cleanName());
302330
assessmentStatus = 'Needs Manual Intervention';

src/migration/omniscript.ts

Lines changed: 114 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
475475
let assessmentStatus: 'Ready for migration' | 'Warnings' | 'Needs Manual Intervention' = 'Ready for migration';
476476

477477
const warnings: string[] = [];
478+
const errors: string[] = [];
479+
480+
// Check for missing mandatory fields for Integration Procedures
481+
if (omniProcessType === 'Integration Procedure') {
482+
if (!existingType || existingType.trim() === '') {
483+
errors.push(this.messages.getMessage('missingMandatoryField', ['Type', 'Integration Procedure']));
484+
assessmentStatus = 'Needs Manual Intervention';
485+
}
486+
if (!existingSubType || existingSubType.trim() === '') {
487+
errors.push(this.messages.getMessage('missingMandatoryField', ['SubType', 'Integration Procedure']));
488+
assessmentStatus = 'Needs Manual Intervention';
489+
}
490+
}
478491

479492
// Check for Angular OmniScript dependencies
480493
for (const osDep of dependencyOS) {
@@ -505,25 +518,36 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
505518
`_${omniscript[this.namespacePrefix + 'Version__c']}`;
506519

507520
if (!existingTypeVal.isNameCleaned()) {
508-
warnings.push(
509-
this.messages.getMessage('changeMessage', [
510-
existingTypeVal.type,
511-
existingTypeVal.val,
512-
existingTypeVal.cleanName(),
513-
])
514-
);
515-
assessmentStatus = 'Warnings';
521+
if (omniProcessType === 'Integration Procedure' && (!newType || newType.trim() === '')) {
522+
warnings.push(this.messages.getMessage('integrationProcedureTypeEmptyAfterCleaning', [existingTypeVal.val]));
523+
assessmentStatus = 'Needs Manual Intervention';
524+
} else {
525+
warnings.push(
526+
this.messages.getMessage('changeMessage', [
527+
existingTypeVal.type,
528+
existingTypeVal.val,
529+
existingTypeVal.cleanName(),
530+
])
531+
);
532+
assessmentStatus = 'Warnings';
533+
}
516534
}
517535
if (!existingSubTypeVal.isNameCleaned()) {
518-
warnings.push(
519-
this.messages.getMessage('changeMessage', [
520-
existingSubTypeVal.type,
521-
existingSubTypeVal.val,
522-
existingSubTypeVal.cleanName(),
523-
])
524-
);
525-
assessmentStatus = 'Warnings';
536+
if (omniProcessType === 'Integration Procedure' && (!newSubType || newSubType.trim() === '')) {
537+
warnings.push(this.messages.getMessage('integrationProcedureSubtypeEmptyAfterCleaning', [existingSubTypeVal.val]));
538+
assessmentStatus = 'Needs Manual Intervention';
539+
} else {
540+
warnings.push(
541+
this.messages.getMessage('changeMessage', [
542+
existingSubTypeVal.type,
543+
existingSubTypeVal.val,
544+
existingSubTypeVal.cleanName(),
545+
])
546+
);
547+
assessmentStatus = 'Warnings';
548+
}
526549
}
550+
527551
if (!existingOmniScriptNameVal.isNameCleaned()) {
528552
warnings.push(
529553
this.messages.getMessage('changeMessage', [
@@ -751,6 +775,42 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
751775
}
752776

753777
if (omniscript[`${this.namespacePrefix}IsProcedure__c`] === true) {
778+
// Check for missing mandatory fields for Integration Procedures
779+
const existingType = omniscript[this.namespacePrefix + 'Type__c'];
780+
const existingSubType = omniscript[this.namespacePrefix + 'SubType__c'];
781+
782+
if (!existingType || existingType.trim() === '') {
783+
const skippedResponse: UploadRecordResult = {
784+
referenceId: recordId,
785+
id: '',
786+
success: false,
787+
hasErrors: true,
788+
errors: [this.messages.getMessage('missingMandatoryField', ['Type', 'Integration Procedure'])],
789+
warnings: [],
790+
newName: '',
791+
skipped: true,
792+
};
793+
osUploadInfo.set(recordId, skippedResponse);
794+
originalOsRecords.set(recordId, omniscript);
795+
continue;
796+
}
797+
798+
if (!existingSubType || existingSubType.trim() === '') {
799+
const skippedResponse: UploadRecordResult = {
800+
referenceId: recordId,
801+
id: '',
802+
success: false,
803+
hasErrors: true,
804+
errors: [this.messages.getMessage('missingMandatoryField', ['SubType', 'Integration Procedure'])],
805+
warnings: [],
806+
newName: '',
807+
skipped: true,
808+
};
809+
osUploadInfo.set(recordId, skippedResponse);
810+
originalOsRecords.set(recordId, omniscript);
811+
continue;
812+
}
813+
754814
// Check for reserved keys in PropertySet for Integration Procedures
755815
const foundReservedKeys = new Set<string>();
756816

@@ -806,6 +866,44 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
806866
mappedOmniScript[OmniScriptMappings.Type__c] = this.cleanName(mappedOmniScript[OmniScriptMappings.Type__c]);
807867
mappedOmniScript[OmniScriptMappings.SubType__c] = this.cleanName(mappedOmniScript[OmniScriptMappings.SubType__c]);
808868

869+
// Check if Type or SubType becomes empty after cleaning for Integration Procedures
870+
if (omniscript[`${this.namespacePrefix}IsProcedure__c`]) {
871+
const originalType = omniscript[this.namespacePrefix + 'Type__c'];
872+
const originalSubType = omniscript[this.namespacePrefix + 'SubType__c'];
873+
874+
if (!mappedOmniScript[OmniScriptMappings.Type__c] || mappedOmniScript[OmniScriptMappings.Type__c].trim() === '') {
875+
const skippedResponse: UploadRecordResult = {
876+
referenceId: recordId,
877+
id: '',
878+
success: false,
879+
hasErrors: true,
880+
errors: [this.messages.getMessage('integrationProcedureTypeEmptyAfterCleaning', [originalType])],
881+
warnings: [],
882+
newName: '',
883+
skipped: true,
884+
};
885+
osUploadInfo.set(recordId, skippedResponse);
886+
originalOsRecords.set(recordId, omniscript);
887+
continue;
888+
}
889+
890+
if (!mappedOmniScript[OmniScriptMappings.SubType__c] || mappedOmniScript[OmniScriptMappings.SubType__c].trim() === '') {
891+
const skippedResponse: UploadRecordResult = {
892+
referenceId: recordId,
893+
id: '',
894+
success: false,
895+
hasErrors: true,
896+
errors: [this.messages.getMessage('integrationProcedureSubtypeEmptyAfterCleaning', [originalSubType])],
897+
warnings: [],
898+
newName: '',
899+
skipped: true,
900+
};
901+
osUploadInfo.set(recordId, skippedResponse);
902+
originalOsRecords.set(recordId, omniscript);
903+
continue;
904+
}
905+
}
906+
809907
// Check duplicated name
810908
let mappedOsName;
811909
if (this.allVersions) {

0 commit comments

Comments
 (0)