It only works if the subfield is connected to an Authorized values list. I created a subfield 099$m with a link with COUNTRY authorized values list and it's OK But, if I try to create a simple subfield 012$z and I've got the following error in logs : DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`marc_subfield_structure`, CONSTRAINT `marc_subfield_structure_ibfk_1` FOREIGN KEY (`authorised_value`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON ) [for Statement "INSERT INTO `marc_subfield_structure` ( `authorised_value`, `authtypecode`, `defaultvalue`, `frameworkcode`, `hidden`, `isurl`, `kohafield`, `liblibrarian`, `libopac`, `link`, `mandatory`, `maxlength`, `repeatable`, `seealso`, `tab`, `tagfield`, `tagsubfield`, `value_builder`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="", 1="", 2="", 3="", 4="0", 5=0, 6="", 7="test", 8="test", 9="", 10=0, 11="9999", 12=0, 13=undef, 14="0", 15="013", 16="x", 17=""] at /usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 1836. Best regards, Corinne
Corinne, can you confirm you still get this error using the last 18.11.x version?
yep, we use 18.11.10
both if you add a subfield using "edit/add subfield" menu or using import framework function
My guess is that the instance does not have the empty string value in authorised_value_categories. Could you: SELECT COUNT(*) FROM authorised_value_categories WHERE category_name=""; If if returns 0 you can insert it using: INSERT INTO authorised_value_categories(category_name) VALUES (""); Is it an old instance?
Lowering severity until it is confirmed.
No answer, closing. Please reopen if still valid.
Sorry for being late. For me, it still doesn't work in 18.11.11 despite we applied the patch. First installation was made with standard koha source (no migration) SQL query : SELECT COUNT(*) FROM authorised_value_categories WHERE category_name=""; give 1 as result. After applying the patch, we can add a subfield but we cannot update framework using import function. Corinne
(In reply to Corinne Hayet from comment #7) > After applying the patch, we can add a subfield but we cannot update > framework using import function. Bonjour Corinne, So it sounds like something else. Can you detail the steps behind "using import function"? See also bug 23398, which may be related ("Export to XML" is broken basically).