From 7f323aaa162461dece5c4cdaf9cd076f5db67522 Mon Sep 17 00:00:00 2001 From: rajatsingh23 <48049052+rajatsingh23@users.noreply.github.com> Date: Wed, 2 Jul 2025 18:38:34 +0530 Subject: [PATCH] Fix Raw Json Null Error (#12968) This pull request refines the `usePersistField` hook in `usePersistField.ts` to improve handling of raw JSON fields. The changes ensure that unpersistable raw JSON fields are excluded early in the logic and simplify the conditions for determining persistable values. Enhancements to raw JSON field handling: * Added a conditional check to exit early if the field is both raw JSON and unpersistable (`usePersistField.ts`). * Simplified the persistability condition by removing redundant checks for unpersistable raw JSON fields (`usePersistField.ts`). --------- Co-authored-by: Baptiste Devessier --- .../object-record/record-field/hooks/usePersistField.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/object-record/record-field/hooks/usePersistField.ts b/packages/twenty-front/src/modules/object-record/record-field/hooks/usePersistField.ts index 6c33a7f9c..8b07dd529 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/hooks/usePersistField.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/hooks/usePersistField.ts @@ -134,6 +134,10 @@ export const usePersistField = () => { fieldName: fieldDefinition.metadata.fieldName, }); + if (fieldIsRawJson && isUnpersistableRawJsonField) { + return; + } + const isValuePersistable = fieldIsRelationToOneObject || fieldIsText || @@ -150,7 +154,7 @@ export const usePersistField = () => { fieldIsSelect || fieldIsMultiSelect || fieldIsAddress || - (fieldIsRawJson && !isUnpersistableRawJsonField) || + fieldIsRawJson || fieldIsArray || fieldIsRichText || fieldIsRichTextV2;