Bug 3426 - Add support for multiple tags to the itemcallnumber system preference
Summary: Add support for multiple tags to the itemcallnumber system preference
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement with 10 votes (vote)
Assignee: Nick Clemens
QA Contact: Bugs List
URL:
Keywords:
Depends on: 9156
Blocks:
  Show dependency treegraph
 
Reported: 2009-07-16 09:46 UTC by Chris Cormack
Modified: 2020-05-18 13:32 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
The itemcallnumber system preference now allows to specify multiple fields from which Koha can pull a suggestion for the itemcallnumber to use when adding items.
Version(s) released in:
20.05.00


Attachments
Bug 3426: Allow for multiple fields in itemcallnumber syspref (4.37 KB, patch)
2019-12-19 05:39 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 3426: Allow for multiple fields in itemcallnumber syspref (6.62 KB, patch)
2019-12-19 19:00 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 3426: Allow for multiple fields in itemcallnumber syspref (6.08 KB, patch)
2019-12-19 23:48 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 3426: Allow for multiple fields in itemcallnumber syspref (6.15 KB, patch)
2019-12-21 14:05 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 3426: Allow for multiple fields in itemcallnumber syspref (6.27 KB, patch)
2020-01-20 21:01 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 3426: Keep note about sequence of subfields (1.94 KB, patch)
2020-01-20 21:01 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Cormack 2010-05-21 01:10:22 UTC


---- Reported by bchurch@ptfs.com 2009-07-16 21:46:23 ----

Currently the "itemcallnumber" system preference only allows the library to enter one MARC tag/subfield to be used to populate the call number field in new item records. It would help if the library could enter multiple tags which Koha would check in the order they were entered. If the first tag was not in the biliographic record, Koha would look for the next tag. For example, the library if the library entered 090ab,082ab, Koha would check the 082 tag if there was no 090 tag.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:10 UTC  ---

This bug was previously known as _bug_ 3426 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3426

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was bchurch@ptfs.com.

Comment 1 Galen Charlton 2011-01-28 18:08:35 UTC
Retargeting to 3.4 and taking this on.

Besides allowing multiple values in the system preference, there are few other ways this could go:

- letting the call number tag hierarchy vary by library (or collection or shelving location)
- if there's more than one call number field in the record, letting the user choose which one to use in case they don't like the default.  This might be as simple as displaying all of the call number fields from the bib record on the item editing form so that the user can copy in paste an alternative value if they don't like the default.
Comment 2 Katrin Fischer 2011-04-25 14:32:40 UTC
It would be nice if the feature would display all options for a repeatable field. At the moment it only copies the first value into the callnumber field as suggestion.
Comment 3 Galen Charlton 2012-08-29 15:36:11 UTC
There's a another variation to consider -- a customer of ours hit on the idea of setting the system preference to '952o'.  Doing this sets the initial call number of a new item to that of the "first" existing item.

This certainly seems like a useful variation, but there should probably be something coded to make this more explicit, as it depends on an a mechanism (embedding item fields in the MARC bib) that isn't necessarily going to survive potential ways that the item editor might be redone in the future.
Comment 4 Manos PETRIDIS 2013-12-30 21:56:50 UTC
While this is still open to discussion, allow me to propose some added functionality/flexibility, i.e. complex expressions in the itemcallnumber system preference. 

For example, I would prefer having call numbers formatted as "999.99 Aut YYYY" where 
- 999.99 are the first five digits of DDC code (in MARC21 092ab entry if filled, otherwise 082ab), padded with trailing zeroes so that DDC 920 would become 920.00 
- Aut are the first three characters of the SOUNDEX of Author name "LEFT(LTRIM(RTRIM(SOUNDEX(biblio.author))), 3)" and 
- YYYY is the copyright year "CONVERT(biblio.copyrightdate, CHAR(4))",
Comment 5 Andrew Fuerste-Henry 2019-12-18 20:40:24 UTC
Hi all! Giving this old bug a bump. I talk to lots of libraries that would like to be able to define something like "050ab, 090ab" so that Koha will first check the 050 and use that call number if present, but, if no 050 is found, will then check the 090 and use that call number instead.
Comment 6 Jessie Zairo 2019-12-18 21:03:43 UTC
I can confirm, this is something we get requests from libraries pretty frequently. This would be a helpful enhancement to be able to define multiple call numbers to check.
Comment 7 Nick Clemens 2019-12-19 05:39:17 UTC
Created attachment 96468 [details] [review]
Bug 3426: Allow for multiple fields in itemcallnumber syspref

Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay

I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script
which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho)

To test:
 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a"
 2 - Find a record with no items
 3 - Ensure it has no 082 field, but an 092 field
 4 - Go to add an item - itemcallnumber is empty
 5 - Apply patch
 6 - Go to add item, itemcallnumber should be the 092ab fields
 7 - Delete the 092 field
 8 - Go to add item, itemcallnumber should be the 245a
 9 - Edit the callnumber to be "testing" and save item
10 - For should now show itemcallnumber="testing" as default
11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber
12 - Ensure the callnumber is defaulting to testing
13 - delete the item you created
14 - browse to URL above - callnumber should now be 245 again
15 - Add an 092 field to record and ensure it is now default callnumber
16 - Add an 082 field, it should now be default
Comment 8 Andrew Fuerste-Henry 2019-12-19 14:19:59 UTC
You probably want to base this on bug 9156.

Also, failing this because it's not properly checking each field in order -- in your example, when the system finds that the 082 is empty it jumps straight to the 245 at the end of the list without checking the 092 and 952.

Also, if we're gonna change how this works then we need to change the syspref text. 

How about:
List multiple comma-separated fields to check them sequentially. Each field can include
multiple subfields. For example: "082ab,092ab" will look in the 082$a and 082$b, then the 092$a and 092$b.
Examples (for MARC21 records): Dewey: 082ab,092ab; LOC: 050ab,090ab; from the item record: 952hi
Comment 9 Nick Clemens 2019-12-19 19:00:34 UTC
Created attachment 96498 [details] [review]
Bug 3426: Allow for multiple fields in itemcallnumber syspref

Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay

I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script
which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho)

To test:
 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a"
 2 - Find a record with no items
 3 - Ensure it has no 082 field, but an 092 field
 4 - Go to add an item - itemcallnumber is empty
 5 - Apply patch
 6 - Go to add item, itemcallnumber should be the 092ab fields
 7 - Delete the 092 field
 8 - Go to add item, itemcallnumber should be the 245a
 9 - Edit the callnumber to be "testing" and save item
10 - For should now show itemcallnumber="testing" as default
11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber
12 - Ensure the callnumber is defaulting to testing
13 - delete the item you created
14 - browse to URL above - callnumber should now be 245 again
15 - Add an 092 field to record and ensure it is now default callnumber
16 - Add an 082 field, it should now be default
Comment 10 Nick Clemens 2019-12-19 23:48:54 UTC
Created attachment 96501 [details] [review]
Bug 3426: Allow for multiple fields in itemcallnumber syspref

Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay

I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script
which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho)

To test:
 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a"
 2 - Find a record with no items
 3 - Ensure it has no 082 field, but an 092 field
 4 - Go to add an item - itemcallnumber is empty
 5 - Apply patch
 6 - Go to add item, itemcallnumber should be the 092ab fields
 7 - Delete the 092 field
 8 - Go to add item, itemcallnumber should be the 245a
 9 - Edit the callnumber to be "testing" and save item
10 - For should now show itemcallnumber="testing" as default
11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber
12 - Ensure the callnumber is defaulting to testing
13 - delete the item you created
14 - browse to URL above - callnumber should now be 245 again
15 - Add an 092 field to record and ensure it is now default callnumber
16 - Add an 082 field, it should now be default
Comment 11 ByWater Sandboxes 2019-12-21 14:05:46 UTC
Created attachment 96559 [details] [review]
Bug 3426: Allow for multiple fields in itemcallnumber syspref

Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay

I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script
which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho)

To test:
 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a"
 2 - Find a record with no items
 3 - Ensure it has no 082 field, but an 092 field
 4 - Go to add an item - itemcallnumber is empty
 5 - Apply patch
 6 - Go to add item, itemcallnumber should be the 092ab fields
 7 - Delete the 092 field
 8 - Go to add item, itemcallnumber should be the 245a
 9 - Edit the callnumber to be "testing" and save item
10 - For should now show itemcallnumber="testing" as default
11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber
12 - Ensure the callnumber is defaulting to testing
13 - delete the item you created
14 - browse to URL above - callnumber should now be 245 again
15 - Add an 092 field to record and ensure it is now default callnumber
16 - Add an 082 field, it should now be default

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 12 Andrew Fuerste-Henry 2019-12-21 14:06:37 UTC
I've got a small quibble over on bug 9156, but this part of things worked as desired. Thanks!
Comment 13 Katrin Fischer 2019-12-22 17:23:28 UTC
Blocked by FQA on bug 9156 - please switch back once this is resolved.
Comment 14 Andrew Fuerste-Henry 2020-01-02 19:09:23 UTC
Switching back to signed off based on work in 9156
Comment 15 Katrin Fischer 2020-01-20 21:01:17 UTC
Created attachment 97636 [details] [review]
Bug 3426: Allow for multiple fields in itemcallnumber syspref

Note that we change both cataloguing/additem.pl and C4/Items->PrepareItemrecordfordisplay

I can find no code that uses callnumber from the C4/Items sub, except for the itemrecorddisplay script
which is not called with an itemnumber from Koha and should be deprecated for REST or ILSDI or OAI (imho)

To test:
 1 - Define itemcallnumber syspref as "082ab,092ab,9520,245a"
 2 - Find a record with no items
 3 - Ensure it has no 082 field, but an 092 field
 4 - Go to add an item - itemcallnumber is empty
 5 - Apply patch
 6 - Go to add item, itemcallnumber should be the 092ab fields
 7 - Delete the 092 field
 8 - Go to add item, itemcallnumber should be the 245a
 9 - Edit the callnumber to be "testing" and save item
10 - For should now show itemcallnumber="testing" as default
11 - Browse to http://localhost:8081/cgi-bin/koha/services/itemrecorddisplay.pl?itemnumber=## subbing the correct itemnumber
12 - Ensure the callnumber is defaulting to testing
13 - delete the item you created
14 - browse to URL above - callnumber should now be 245 again
15 - Add an 092 field to record and ensure it is now default callnumber
16 - Add an 082 field, it should now be default

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Katrin Fischer 2020-01-20 21:01:23 UTC
Created attachment 97637 [details] [review]
Bug 3426: Keep note about sequence of subfields

Bug 9156 changed the wording of the pref slightly to make it
clear that the subfield sequence of the record will be used,
not the sequence of the subfields defined in the pref.

This just reinstates the note:
The order of the subfields in the record will be preserved.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 17 Martin Renvoize 2020-01-21 11:27:19 UTC
Love seeing these golden oldies getting some attention!
Comment 18 Martin Renvoize 2020-01-21 11:36:35 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 19 Joy Nelson 2020-01-31 21:32:51 UTC
Enhancement not backported to 19.11 branch
Comment 20 Joy Nelson 2020-02-06 22:30:56 UTC
Enhancement not backported to 19.11.x