Create a 001 field if it doesn't exist in marc_export
[evergreen-equinox.git] / Open-ILS / src / support-scripts / marc_export
index ecd79a5..3fe5ec1 100755 (executable)
@@ -278,7 +278,12 @@ sub export_record {
 
         if ($replace_001) {
             my $tcn = $r->field('001');
-            $tcn->update($id);
+            if ($tcn) {
+                $tcn->update($id);
+            } else {
+                my $new_001 = MARC::Field->new('001', $id);
+                $r->insert_fields_ordered($new_001);
+            }
         }
 
         if ($format eq 'XML') {