From 485670c823d0ad5c57a7966a52d894a48e0b9958 Mon Sep 17 00:00:00 2001 From: "gitstart-app[bot]" <57568882+gitstart-app[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:24:23 +0200 Subject: [PATCH] Add relation in CSV exports (#5085) ### Description Add Relation Id to Table in CSV exports ### Demo Before: After: Co-authored-by: gitstart-twenty Co-authored-by: Lucas Bordeau Co-authored-by: v1b3m Co-authored-by: Chiazokam --- .../record-index/options/hooks/useExportTableData.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useExportTableData.ts b/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useExportTableData.ts index d9c9f26f0..e67c4d197 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useExportTableData.ts +++ b/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useExportTableData.ts @@ -34,14 +34,16 @@ export const generateCsv: GenerateExport = ({ columns, rows, }: GenerateExportOptions): string => { - const columnsWithoutRelations = columns.filter( - (col) => !('relationType' in col.metadata && col.metadata.relationType), + const columnsToExport = columns.filter( + (col) => + !('relationType' in col.metadata && col.metadata.relationType) || + col.metadata.relationType === 'TO_ONE_OBJECT', ); - const keys = columnsWithoutRelations.flatMap((col) => { + const keys = columnsToExport.flatMap((col) => { const column = { - field: col.metadata.fieldName, - title: col.label, + field: `${col.metadata.fieldName}${col.type === 'RELATION' ? 'Id' : ''}`, + title: `${col.label} ${col.type === 'RELATION' ? 'Id' : ''}`, }; const fieldsWithSubFields = rows.find((row) => {