From 1a6c01a51c462ec3b67f3d5ff5f7e3aa74a62e73 Mon Sep 17 00:00:00 2001 From: Alex <52550827+alex-wilson-gwf@users.noreply.github.com> Date: Thu, 27 Apr 2023 15:14:23 +1000 Subject: [PATCH] Update MetadataUtil.cls Relates to issue https://github.com/forcedotcom/CustomMetadataLoader/issues/45 I assume these lines were originally introduced to handle poorly formatted CSV with blank 'columns' at the end. If there was another reason, then this fix may not be valid. Simply removing these lines allows correctly formatted CSV with empty values to be handled correctly. --- custom_md_loader/classes/MetadataUtil.cls | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_md_loader/classes/MetadataUtil.cls b/custom_md_loader/classes/MetadataUtil.cls index a1e6650..9ed1f29 100644 --- a/custom_md_loader/classes/MetadataUtil.cls +++ b/custom_md_loader/classes/MetadataUtil.cls @@ -64,9 +64,10 @@ public class MetadataUtil { // it would pass the conditions under isHeadervalid() Set fieldNameSet = new Set(); for (String fieldNames :header) { - if (String.isBlank(fieldNames)) { - continue; - } + //removed following lines as redundant, since if any columns have a blank header, they are captured by 'Header must contain the api names of the fields' error + //if (String.isBlank(fieldNames)) { + // continue; + //} fieldNameSet.addAll(fieldNames.split(';')); } @@ -87,9 +88,10 @@ public class MetadataUtil { List fieldValueList = new List(); for (String singleRowFieldValues :singleRowOfValues) { - if (String.isBlank(singleRowFieldValues)) { - continue; - } + //Removed following lines as they cause values to become misaligned from headers when CSV contains null values + //if (String.isBlank(singleRowFieldValues)) { + // continue; + //} fieldValueList.addAll(singleRowFieldValues.split(';')); }