Skip to content

Conversation

@AishDani
Copy link
Contributor

@AishDani AishDani commented Dec 9, 2025

…d UID checks

@AishDani AishDani requested a review from a team as a code owner December 9, 2025 10:07
@AishDani AishDani requested review from sayalijoshi27 and umeshmore45 and removed request for a team December 9, 2025 10:07
}

export function buildSchemaTree(fields: any[], parentUid = '', parentType = ''): any[] {
export function buildSchemaTree(fields: any[], parentUid = '', parentType = '', oldPrentUid = ''): any[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oldPrentUid correct the spelling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// Fallback: check if field is a direct child of oldPrentUid (if provided and different)
if (oldPrentUid && oldPrentUid !== parentUid && fieldUid.startsWith(oldPrentUid + '.')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct the spelling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const remainder = fieldUid.substring(oldPrentUid.length + 1);
// Verify it's exactly one level deeper (no more dots in remainder)
return remainder && !remainder.includes('.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add null checks in above function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (oldFieldtUid && fUid.startsWith(oldFieldtUid + '.')) {
const remainder = fUid.substring(oldFieldtUid.length + 1);
return remainder && !remainder.includes('.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add null checks in above block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

uid: childUid,
display_name: childDisplay,
schema: buildSchemaTree(fields, child.contentstackFieldUid, 'modular_blocks_child')
schema: buildSchemaTree(fields, child.contentstackFieldUid, 'modular_blocks_child', child?.backupFieldUid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child?.contentstackFieldUid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the backFieldUId to get the nested child of it if it is mapped to another field

(fieldType === 'modular_blocks_child' && hasChildren)) {
// Recursively build schema for groups and modular block children with nested content
result.schema = buildSchemaTree(fields, fieldUid, fieldType);
result.schema = buildSchemaTree(fields, fieldUid, fieldType, oldFieldtUid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be oldFieldUid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sayalijoshi27 sayalijoshi27 merged commit 1dbf2d7 into dev Dec 10, 2025
7 checks passed
@sayalijoshi27 sayalijoshi27 deleted the bugfix/sitecore-bugs/cmg-785 branch December 10, 2025 09:59
@sayalijoshi27 sayalijoshi27 restored the bugfix/sitecore-bugs/cmg-785 branch December 10, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants