Created attachment 146586 [details] mrc with multiple 020 fields including 020$z Moving one subfield to another fails for repeatable fields where the field to be moved doesn't exist in the first instance 1. Make marcmodtemplate as follows a. Move every 020 z field to field 020 a 2. Stage marc exchange file (attached) with following in 020 field (note only 7th and 8th have 020z and these are the ones we wish to move to subfield a) =020 \\$a9781003182870$q(ebk) =020 \\$a1003182879 =020 \\$a9781000407204$q(electronic bk. : EPUB) =020 \\$a1000407209$q(electronic bk. : EPUB) =020 \\$a9781000407167$q(electronic bk. : PDF) =020 \\$a1000407160$q(electronic bk. : PDF) =020 \\$z9781032023175$q(hbk.) =020 \\$z9780367760380$q(pbk.) 3. view staged record and observe fields 020 subfield a fields have all gone and subfield z has not been moved, but its value removed: 020 _a _q(ebk) 020 _a 020 _a _q(electronic bk. : EPUB) 020 _a _q(electronic bk. : EPUB) 020 _a _q(electronic bk. : PDF) 020 _a _q(electronic bk. : PDF) 020 _q(hbk.) _a 020 _q(pbk.) _a Note, adding a conditional to marcmodtemplate "only do this if 020 z subfield exists makes no difference.
In case it helps, I believe the problem occurs at line 616 in Koha/SimpleMARC.pm if ( @$field_numbers ) { @values = map { $_ <= @values ? $values[ $_ - 1 ] : () } @$field_numbers; } @values is empty after these lines have run.