From 0add075a064e2af148405dbc54ac64952fbee6e7 Mon Sep 17 00:00:00 2001 From: Leonardo Viva Date: Wed, 26 Jun 2024 15:40:02 -0300 Subject: [PATCH] fix: dont remove inherited fields if it's sent on request --- src/imports/meta/removeInheritedFields.js | 4 ++-- src/imports/meta/validateAndProcessValueFor.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/imports/meta/removeInheritedFields.js b/src/imports/meta/removeInheritedFields.js index f0854840..e7559a7a 100644 --- a/src/imports/meta/removeInheritedFields.js +++ b/src/imports/meta/removeInheritedFields.js @@ -1,9 +1,9 @@ import isArray from 'lodash/isArray'; -export function removeInheritedFields(lookupField) { +export function removeInheritedFields(lookupField, objectNewValues) { if (isArray(lookupField.inheritedFields)) { return lookupField.inheritedFields.reduce((acc, inheritedField) => { - if (['always', 'hierarchy_always'].includes(inheritedField.inherit)) { + if (['always', 'hierarchy_always'].includes(inheritedField.inherit) && objectNewValues[inheritedField.fieldName] === undefined) { acc[inheritedField.fieldName] = null; } return acc; diff --git a/src/imports/meta/validateAndProcessValueFor.js b/src/imports/meta/validateAndProcessValueFor.js index 00b0382d..8143dfd7 100644 --- a/src/imports/meta/validateAndProcessValueFor.js +++ b/src/imports/meta/validateAndProcessValueFor.js @@ -123,7 +123,7 @@ export async function validateAndProcessValueFor({ meta, fieldName, value, actio } if (actionType === 'update' && value == null && field.type === 'lookup') { - Object.assign(objectNewValues, removeInheritedFields(field)); + Object.assign(objectNewValues, removeInheritedFields(field, objectNewValues)); } if (value == null && field.type !== 'autoNumber') {