From dc30d4c3768146f23931d2c1f97a9669346465fe Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 30 Sep 2021 13:39:59 +0000 Subject: [PATCH] Bug 29146: Apply framework defaultvalue only to new records This applies only to the 'regular' cataloguing editor. Another report could be opened for the advanced one, if needed. Test plan: [1] Add a default value to some field X in framework Y. [2] Open an existing biblio record in that fw. Clear field X. Save. [3] Reopen the record. The default should not be in field X. [4] Add a new record in that fw. You should see default value in X. Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- cataloguing/addbiblio.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 89a68e06f8..090849da4d 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -288,8 +288,9 @@ sub create_input { my $index_subfield = CreateKey(); # create a specifique key for each subfield - # if there is no value provided but a default value in parameters, get it - if ( $value eq '' ) { + # Apply optional framework default value when it is a new record + # Substitute date parts, user name + if ( $value eq '' && !$cgi->param('biblionumber') ) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; # get today date & replace <>, <>, <>, <
> if provided in the default value @@ -305,8 +306,8 @@ sub create_input { # And <> with surname (?) my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian"); $value=~s/<>/$username/g; - } + my $dbh = C4::Context->dbh; # map '@' as "subfield" label for fixed fields -- 2.39.5