Merge branch 'master' of git://git.sitka.bclibraries.ca/sitka/sitka-tools
[sitka/sitka-tools.git] / marc_export_custom / marc_export_custom
index 0580218..ed05f99 100755 (executable)
@@ -244,6 +244,18 @@ sub export_record {
             add_bib_holdings($bib, $r);
         }
 
+        if($force901){
+            $r->delete_field( $r->field('901') );
+            $r->append_fields(
+                MARC::Field->new(
+                    '901', ' ', ' ',
+                    a => $bib->tcn_value,
+                    b => $bib->tcn_source,
+                    c => $bib->id
+                )
+            );
+        }
+
         if ($format eq 'XML') {
             my $xml = $r->as_xml_record;
             $xml =~ s/^<\?.+?\?>$//mo;
@@ -271,6 +283,18 @@ sub export_record {
             try {
                 my $r = MARC::Record->new_from_xml( $mfhd->marc, $encoding, $format );
 
+                if($force901){
+                    $r->delete_field( $r->field('901') );
+                    $r->append_fields(
+                        MARC::Field->new(
+                            '901', ' ', ' ',
+                            a => $bib->tcn_value,
+                            b => $bib->tcn_source,
+                            c => $bib->id
+                        )
+                    );
+                }
+
                 if ($format eq 'XML') {
                     my $xml = $r->as_xml_record;
                     $xml =~ s/^<\?.+?\?>$//mo;
@@ -557,18 +581,7 @@ sub add_bib_holdings {
                         )
                     );
 
-                    if($force901){
-                        $r->delete_field( $r->field('901') );
-                        $r->append_fields(
-                            MARC::Field->new(
-                                '901', ' ', ' ',
-                                a => $bib->tcn_value,
-                                b => $bib->tcn_source,
-                                c => $bib->id
-                            )
-                        );
 
-                    }
 
                     stats() if (! ($count{cp} % 100 ));
                 } # for cnmap