From e14c79d37c104dd9326bfcdfdf496d56ae284610 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 19 Mar 2020 04:37:34 +0000 Subject: [PATCH] Bug 24900: If condition in template, check for existence of from fields in MARC record This patch checks the existence of 'from fields' in the record, as defined in the template, if the template includes a condition. To test: Follow plan to reproduce the bug Apply the patch and go back to import the record (Tools -> Stage MARC record for import) Under Use MARC modification template, select your template to modify the record Stage for import Once complete, go to Manage staged records Click the staged record to view the MARC Confirm all 020 fields were deleted, as expected Sponsored-by: Catalyst IT --- C4/MarcModificationTemplates.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm index 54846e5..219c518 100644 --- a/C4/MarcModificationTemplates.pm +++ b/C4/MarcModificationTemplates.pm @@ -601,6 +601,12 @@ sub ModifyRecordWithTemplate { if ( $field_number == 1 ) { # We want only the first matching $field_numbers = [ $field_numbers->[0] ]; + } else { + $field_numbers = field_exists({ + record => $record, + field => $from_field, + subfield => $from_subfield, + }); } } # There was no condition -- 2.1.4