+
+my $file_id = $biblionumber;
+my $file_pre = "bib-";
+if( C4::Context->preference('DefaultSaveRecordFileID') eq 'controlnumber' ){
+ my $marcflavour = C4::Context->preference('marcflavour'); #FIXME This option is required but does not change control num behaviour
+ my $control_num = GetMarcControlnumber( $marc, $marcflavour );
+ if( $control_num ){
+ $file_id = $control_num;
+ $file_pre = "record-";
+ }
+}
+
+# ASSERT: There is a biblionumber, because GetMarcBiblio returned something.
+my $framework = GetFrameworkCode( $biblionumber );
+my $record_processor = Koha::RecordProcessor->new({
+ filters => 'ViewPolicy',
+ options => {
+ interface => 'opac',
+ frameworkcode => $framework
+ }
+});
+$record_processor->process($marc);
+
+if ($format =~ /endnote/) {