=head3 FillWithDefaultValues
-FillWithDefaultValues( $marc_record );
+FillWithDefaultValues( $marc_record, $params );
This will update the record with default value defined in the ACQ framework.
For all existing fields, if a default value exists and there are no subfield, it will be created.
If the field does not exist, it will be created too.
+If the parameter only_mandatory => 1 is passed via $params, only the mandatory
+defaults are being applied to the record.
+
=cut
sub FillWithDefaultValues {
- my ($record) = @_;
+ my ( $record, $params ) = @_;
+ my $mandatory = $params->{only_mandatory};
my $tagslib = C4::Biblio::GetMarcStructure( 1, 'ACQ', { unsafe => 1 } );
if ($tagslib) {
my ($itemfield) =
next if $tag == $itemfield;
for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
+ next if $mandatory && !$tagslib->{$tag}{$subfield}{mandatory};
my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue};
if ( defined $defaultvalue and $defaultvalue ne '' ) {
my @fields = $record->field($tag);
exit;
}
#from this point: add a new record
+ C4::Acquisition::FillWithDefaultValues($marcrecord, {only_mandatory => 1});
my $bibitemnum;
$params->{'frameworkcode'} or $params->{'frameworkcode'} = "";
( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $params->{'frameworkcode'} );