Bug 40997 - Javascript error prevents saving when an instance of an 'important' or 'required' field is deleted
Summary: Javascript error prevents saving when an instance of an 'important' or 'requi...
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Nick Clemens (kidclamp)
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-10 15:34 UTC by Nick Clemens (kidclamp)
Modified: 2025-11-10 15:00 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00,25.05.05,24.11.11
Circulation function:


Attachments
Bug 40997: Don't check elements that have been removed (989 bytes, patch)
2025-10-10 18:44 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 40997: Remove uneccessary whitespace (3.86 KB, patch)
2025-10-10 18:44 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 40997: Don't check elements that have been removed (1.02 KB, patch)
2025-10-15 18:03 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 40997: Remove uneccessary whitespace (3.91 KB, patch)
2025-10-15 18:03 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 40997: Remove uneccessary whitespace (4.01 KB, patch)
2025-10-17 09:57 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2025-10-10 15:34:22 UTC
When a record has multiple instances of a field marked as 'important' and a cataloger removes one or more of the instances, and one is left in place, saving the record fails with:

Uncaught TypeError: can't access property "getElementsByTagName", elem is null
    AreFieldsNotOk http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=0&z3950=1&frameworkcode=Default&breedingid=38:3841
    Check http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=0&z3950=1&frameworkcode=Default&breedingid=38:3923
    onOption http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=0&z3950=1&frameworkcode=Default&breedingid=38:782
    <anonymous> http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=0&z3950=1&frameworkcode=Default&breedingid=38:698
    jQuery 2


To recreate:
1 - In Admin - MARC bibliographic frameworks  edit the default framewwork and edit 650 tag and mark it as important
2 - Go to cataloging -> new from z39.50
3 - Find a record with mulltiple 650 fields
4 - Delete one of the fields
5 - Attempt to save the record - nothing happens
6 - Check the console log in the browser, see the error noted above
Comment 1 Nick Clemens (kidclamp) 2025-10-10 18:44:30 UTC
Created attachment 187766 [details] [review]
Bug 40997: Don't check elements that have been removed
Comment 2 Nick Clemens (kidclamp) 2025-10-10 18:44:34 UTC
Created attachment 187767 [details] [review]
Bug 40997: Remove uneccessary whitespace
Comment 3 Brendan Lawlor 2025-10-15 18:03:55 UTC
Created attachment 187927 [details] [review]
Bug 40997: Don't check elements that have been removed

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 4 Brendan Lawlor 2025-10-15 18:03:57 UTC
Created attachment 187928 [details] [review]
Bug 40997: Remove uneccessary whitespace

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 5 Brendan Lawlor 2025-10-15 18:10:14 UTC
When I first tried testing this I was unable to import a record from z39.50 because of bug 40272.

This patch works as described.

It may be obvious to library folks, but wasn't to me right away, how to easily find a record with multiple 650s you can do the z39.50 search for author 'patterson, james'
Comment 6 Marcel de Rooy 2025-10-17 09:57:19 UTC
Created attachment 188056 [details] [review]
Bug 40997: Remove uneccessary whitespace

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Lucas Gass (lukeg) 2025-10-20 16:14:45 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 8 Paul Derscheid 2025-10-29 09:10:29 UTC
Nice work everyone!

Pushed to 25.05.x
Comment 9 Fridolin Somers 2025-11-10 15:00:12 UTC
Pushed to 24.11.x for 24.11.11