diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 9c52063cbd..25c6bfc545 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -384,7 +384,7 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue? for (const field of (args.metaValue || meta.value)?.columns ?? []) { if (isVirtualCol(field)) continue if (currentRow.row[field.title!] !== currentRow.oldRow[field.title!]) { - await updateOrSaveRow(currentRow, field.title!, args) + await updateOrSaveRow(currentRow, field.title!, {}, args) } } } diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index cf3d760502..86eb3bc6c8 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -240,14 +240,20 @@ export function useViewData( } } + // inside this method use metaValue and viewMetaValue to refer meta + // since sometimes we need to pass old metas async function updateRowProperty( toUpdate: Row, property: string, { metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, ) { if (toUpdate.rowMeta) toUpdate.rowMeta.saving = true + + // if the field name is missing return + if (!property) return + try { - const id = extractPkFromRow(toUpdate.row, meta.value?.columns as ColumnType[]) + const id = extractPkFromRow(toUpdate.row, metaValue?.columns as ColumnType[]) const updatedRowData = await $api.dbViewRow.update( NOCO, @@ -256,7 +262,8 @@ export function useViewData( viewMetaValue?.id as string, id, { - [property]: toUpdate.row[property], + // if value is undefined treat it as null + [property]: toUpdate.row[property] ?? null, }, // todo: // {