From d27f734b072a1015f057b93ba3c5b340a7edd539 Mon Sep 17 00:00:00 2001 From: Rohan Port <59544282+rohan-bes@users.noreply.github.com> Date: Mon, 17 Oct 2022 16:53:43 +1100 Subject: [PATCH] [no-issue]: Fixed unexpected errors when performing 'insertNumberOfFacilities' alias transform on an empty table (#4227) --- .../reportBuilder/transform/aliases/entityMetadataAliases.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts b/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts index f32bcbc192..47634f045e 100644 --- a/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts +++ b/packages/report-server/src/reportBuilder/transform/aliases/entityMetadataAliases.ts @@ -27,6 +27,10 @@ export const insertNumberOfFacilitiesColumn = { ); } + if (table.length() === 0) { + return table; // Skip if the table is empty + } + const organisationUnitValues = table.getColumnValues('organisationUnit'); const numberOfFacilitiesColumnValues = organisationUnitValues.map(organisationUnit => { if (typeof organisationUnit !== 'string') {