Skip to content

Commit

Permalink
fix incorrect warnings for Order__c and Level__c property
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeneos committed Aug 30, 2024
1 parent 9474d7b commit 50f2b08
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/vlocity-deploy/src/deploymentSpecs/omniScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ export class OmniScript implements DatapackDeploymentSpec {
const parentKey = element.ParentElementId__c?.VlocityMatchingRecordSourceKey ?? 'root';
const orderInParent = (elementCountByParent.get(parentKey) ?? 0) + 1;

const currentLevel = element['%vlocity_namespace%__Level__c'];
const currentOrder = element['%vlocity_namespace%__Order__c'];
const currentLevel = parseInt(element['%vlocity_namespace%__Level__c']);
const currentOrder = parseInt(element['%vlocity_namespace%__Order__c']);
const calculatedLevel = getElementLevel(element);

if (currentOrder !== undefined && currentOrder < orderInParent) {
if (!isNaN(currentOrder) && currentOrder < orderInParent) {
this.addPreprocessingWarning(datapack, `element "${element.Name}" expected "Order__c" to be "${orderInParent}"; instead saw "${currentOrder}"`);
}

if (currentLevel !== undefined && currentLevel !== calculatedLevel) {
this.addPreprocessingWarning(datapack, `element "${element.Name}" expected "Level__c" to be "${orderInParent}"; instead saw "${currentOrder}"`);
if (!isNaN(currentLevel) && currentLevel !== calculatedLevel) {
this.addPreprocessingWarning(datapack, `element "${element.Name}" expected "Level__c" to be "${currentLevel}"; instead saw "${calculatedLevel}"`);
}

currentOrder === undefined && (element['%vlocity_namespace%__Order__c'] = orderInParent);
currentLevel === undefined && (element['%vlocity_namespace%__Level__c'] = calculatedLevel);
/* eslint-disable @typescript-eslint/no-unused-expressions */
isNaN(currentOrder) && (element['%vlocity_namespace%__Order__c'] = orderInParent);
isNaN(currentLevel) && (element['%vlocity_namespace%__Level__c'] = calculatedLevel);

elementCountByParent.set(parentKey, orderInParent);
}
Expand Down

0 comments on commit 50f2b08

Please sign in to comment.