Bug 9156 - System preference itemcallnumber not pulling more than 2 subfields
Summary: System preference itemcallnumber not pulling more than 2 subfields
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 3426
  Show dependency treegraph
 
Reported: 2012-11-27 20:20 UTC by Nicole C. Engard
Modified: 2021-06-14 21:29 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.03
Circulation function:


Attachments
090 in the marc record (29.67 KB, image/png)
2012-11-27 20:20 UTC, Nicole C. Engard
Details
call number on item (11.99 KB, image/png)
2012-11-27 20:20 UTC, Nicole C. Engard
Details
Bug 9156: itemcallnumber not pulling more than 2 subfields (2.76 KB, patch)
2019-11-19 16:41 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 9156: itemcallnumber not pulling more than 2 subfields (2.82 KB, patch)
2019-12-19 14:33 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 9156: (follow-up) Simpliy code (1.51 KB, patch)
2019-12-19 19:06 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 9156: Clarify order in the syspref (2.43 KB, patch)
2020-01-02 18:06 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 9156: (follow-up) Simpliy code (1.58 KB, patch)
2020-01-02 19:08 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 9156: Clarify order in the syspref (2.50 KB, patch)
2020-01-02 19:08 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 9156: Clarify order in the syspref (1.72 KB, patch)
2020-01-03 12:46 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 9156: itemcallnumber not pulling more than 2 subfields (2.89 KB, patch)
2020-01-10 12:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 9156: (follow-up) Simpliy code (1.65 KB, patch)
2020-01-10 12:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 9156: Clarify order in the syspref (1.79 KB, patch)
2020-01-10 12:28 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nicole C. Engard 2012-11-27 20:20:18 UTC
Created attachment 13711 [details]
090 in the marc record

I have itemcallnumber set to 090abvy but it's only pulling subfields ab from the attached record.

This preference should pull all subfields listed.
Comment 1 Nicole C. Engard 2012-11-27 20:20:33 UTC
Created attachment 13712 [details]
call number on item
Comment 2 Owen Leonard 2014-07-16 18:11:02 UTC
How do you reproduce this bug?
Comment 3 Katrin Fischer 2014-07-20 20:56:24 UTC
I think what I'd try is adding a 090 with all the listed subfields to a record. Then set itemcallnumber to 090abvy and create an item from the record. It should pull all subfields.

Bug 3426 seems similar.
Comment 4 Zeno Tajoli 2017-12-05 07:21:52 UTC
To fix the probblrm we need to work on line 149 - 160 of ../cataloguing/additem.pl.
The lines are:
        
 149         my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
 150         if (!$value && $subfieldlib->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) {
 151             my $CNtag       = substr($pref_itemcallnumber, 0, 3);
 152             my $CNsubfield  = substr($pref_itemcallnumber, 3, 1);
 153             my $CNsubfield2 = substr($pref_itemcallnumber, 4, 1);
 154             my $temp2 = $temp->field($CNtag);
 155             if ($temp2) {
 156                 $value = ($temp2->subfield($CNsubfield)).' '.($temp2->subfield($CNsubfield2));
 157                 #remove any trailing space incase one subfield is used
 158                 $value =~ s/^\s+|\s+$//g;
 159             }
 160         }

It is clear that first and second subfields are user.
Inside '$temp' you find bibliographic record data.
Comment 5 Owen Leonard 2019-11-19 16:41:24 UTC
Created attachment 95580 [details] [review]
Bug 9156: itemcallnumber not pulling more than 2 subfields

When the itemcallnumber system preference is defined, the item add form
pulls data from the specified tag and subfield(s) to pre-populate the
call number field. This update makes it possible to build the
prepopulated callnumber from more than just the first two subfields.

To test, apply the patch and update the itemcallnumber system preference
so that it includes more than two subfields. For instance, "092abef"

 - Edit a bibliographic record and populate the specified subfields.
   e.g. subfield a -> "One", b-> "Two", e-> "Three", f-> "Four".
 - Save the record and go to the add/edit items screen.
 - The call number field should contain a string which contains each of
   the subfields you populated, concatenated with spaces: "One Two Three
   Four."
 - Test with other numbers of subfields.
 - Test with an empty itemcallnumber preference.
Comment 6 Séverine Queune 2019-11-20 09:51:32 UTC
Hi Owen, 
I had 2 issues during my tests.
The itemcallnumber field is not populated when I add the item, I need to modify it and save it a second time.
I know it's not allowed in MARC21, but we have in our Unimarc item framework both upper and lower case and the patch only works with Upper case.
Do you think it can be case sensitive ? (if I remember well, I think Katrin can be also concerned).
Comment 7 Owen Leonard 2019-12-10 18:49:56 UTC
Séverine I wasn't able to reproduce either of these problems. Could you test again and see if luck shines on me?
Comment 8 ByWater Sandboxes 2019-12-19 14:33:25 UTC
Created attachment 96486 [details] [review]
Bug 9156: itemcallnumber not pulling more than 2 subfields

When the itemcallnumber system preference is defined, the item add form
pulls data from the specified tag and subfield(s) to pre-populate the
call number field. This update makes it possible to build the
prepopulated callnumber from more than just the first two subfields.

To test, apply the patch and update the itemcallnumber system preference
so that it includes more than two subfields. For instance, "092abef"

 - Edit a bibliographic record and populate the specified subfields.
   e.g. subfield a -> "One", b-> "Two", e-> "Three", f-> "Four".
 - Save the record and go to the add/edit items screen.
 - The call number field should contain a string which contains each of
   the subfields you populated, concatenated with spaces: "One Two Three
   Four."
 - Test with other numbers of subfields.
 - Test with an empty itemcallnumber preference.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 9 Andrew Fuerste-Henry 2019-12-19 14:34:51 UTC
Owen's test plan worked for me. I could not replicate Séverine's issues. I added a subfield A and Koha correctly handled both a and A.
Comment 10 Nick Clemens (kidclamp) 2019-12-19 19:06:35 UTC
Created attachment 96499 [details] [review]
Bug 9156: (follow-up) Simpliy code

The MARC::Field as_string method can join multiple subfield using a delimiter, this simplifies the code here
Comment 11 Andrew Fuerste-Henry 2019-12-21 13:54:01 UTC
After Nick's change, this is misbehaving slightly, not getting the right order in the item record.

My syspref says: 082abmqA

My bib says:
082 $a a
    $b b
    $m m
    $q q
    $A A

The item call number generates as: a A b m q
Comment 12 Katrin Fischer 2019-12-22 17:22:29 UTC
Failing QA because of Andrew's comment.
Comment 13 Nick Clemens (kidclamp) 2019-12-23 19:38:26 UTC
(In reply to Andrew Fuerste-Henry from comment #11)
> After Nick's change, this is misbehaving slightly, not getting the right
> order in the item record.
> 
> My syspref says: 082abmqA
> 
> My bib says:
> 082 $a a
>     $b b
>     $m m
>     $q q
>     $A A
> 
> The item call number generates as: a A b m q

I cannot recreate this - the code for MARC::Field->as_string should preserve the order in the record. Can you share your sample record?
Comment 14 Nick Clemens (kidclamp) 2020-01-02 18:06:39 UTC
Created attachment 96764 [details] [review]
Bug 9156: Clarify order in the syspref
Comment 15 Nick Clemens (kidclamp) 2020-01-02 18:07:43 UTC
(In reply to Katrin Fischer from comment #12)
> Failing QA because of Andrew's comment.

Spoke with Andrew, we agreed order in record should preserved, attached a follow-up to be explicit about this in the pref
Comment 16 ByWater Sandboxes 2020-01-02 19:08:01 UTC
Created attachment 96766 [details] [review]
Bug 9156: (follow-up) Simpliy code

The MARC::Field as_string method can join multiple subfield using a delimiter, this simplifies the code here

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 17 ByWater Sandboxes 2020-01-02 19:08:04 UTC
Created attachment 96767 [details] [review]
Bug 9156: Clarify order in the syspref

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 18 Andrew Fuerste-Henry 2020-01-02 19:08:46 UTC
signing off again based on clarification
Comment 19 Katrin Fischer 2020-01-02 21:44:02 UTC
Comment on attachment 96767 [details] [review]
Bug 9156: Clarify order in the syspref

Review of attachment 96767 [details] [review]:
-----------------------------------------------------------------

::: C4/Reserves.pm
@@ +1195,5 @@
>      # FIXME - a lot of places in the code do this
>      #         or something similar - need to be
>      #         consolidated
> +    my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
> +    my $notforloan_per_itemtype = defined $itemtype ? $itemtype->notforloan : 0;

I think this got in by accident - can you please resubmit the patch?
Comment 20 Nick Clemens (kidclamp) 2020-01-03 12:46:26 UTC
Created attachment 96792 [details] [review]
Bug 9156: Clarify order in the syspref
Comment 21 Jonathan Druart 2020-01-10 11:59:38 UTC
(In reply to Nick Clemens from comment #13)
> (In reply to Andrew Fuerste-Henry from comment #11)
> > After Nick's change, this is misbehaving slightly, not getting the right
> > order in the item record.
> > 
> > My syspref says: 082abmqA
> > 
> > My bib says:
> > 082 $a a
> >     $b b
> >     $m m
> >     $q q
> >     $A A
> > 
> > The item call number generates as: a A b m q
> 
> I cannot recreate this - the code for MARC::Field->as_string should preserve
> the order in the record. Can you share your sample record?

It preserves the order in the record, but not the one from the syspref.

From the test plan, if I edit the pref and set 082$efab it does not change anything. Should not we follow the order of the syspref?
Comment 22 Nick Clemens (kidclamp) 2020-01-10 12:15:01 UTC
We can't both preserve record order and obey syspref order.

Talking it over with Andrew and the educators we agreed the record order should be preserved
Comment 23 Katrin Fischer 2020-01-10 12:19:43 UTC
(In reply to Nick Clemens from comment #22)
> We can't both preserve record order and obey syspref order.
> 
> Talking it over with Andrew and the educators we agreed the record order
> should be preserved

Order in the recod with a clear note on the pref like done here makes sense to me.
Comment 24 Jonathan Druart 2020-01-10 12:28:09 UTC
Created attachment 97190 [details] [review]
Bug 9156: itemcallnumber not pulling more than 2 subfields

When the itemcallnumber system preference is defined, the item add form
pulls data from the specified tag and subfield(s) to pre-populate the
call number field. This update makes it possible to build the
prepopulated callnumber from more than just the first two subfields.

To test, apply the patch and update the itemcallnumber system preference
so that it includes more than two subfields. For instance, "092abef"

 - Edit a bibliographic record and populate the specified subfields.
   e.g. subfield a -> "One", b-> "Two", e-> "Three", f-> "Four".
 - Save the record and go to the add/edit items screen.
 - The call number field should contain a string which contains each of
   the subfields you populated, concatenated with spaces: "One Two Three
   Four."
 - Test with other numbers of subfields.
 - Test with an empty itemcallnumber preference.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 25 Jonathan Druart 2020-01-10 12:28:13 UTC
Created attachment 97191 [details] [review]
Bug 9156: (follow-up) Simpliy code

The MARC::Field as_string method can join multiple subfield using a delimiter, this simplifies the code here

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 26 Jonathan Druart 2020-01-10 12:28:17 UTC
Created attachment 97192 [details] [review]
Bug 9156: Clarify order in the syspref

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 27 Martin Renvoize (ashimema) 2020-01-10 16:23:14 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 28 Joy Nelson 2020-01-31 21:31:45 UTC
Pushed to 19.11.x branch for 19.11.03