I'm trying to set up Mantis for a small company's software team. They previously relied on a spreadsheet to keep a record of bugs and new features, and since this spreadsheet is quite large I have written an SQL script to 'inject' the issues into Mantis rather than doing it manually.
The script I'm using is basically:
use bugtracker;
insert into mantis_bug_text_table (description, additional_information) VALUES ('Issue #1 Description','Originated by X');
insert into mantis_bug_table ( project_id,reporter_id, handler_id,duplicate_id,priority,severity, reproducibility,status, resolution,projection, category_id,date_submitted, last_updated,eta, bug_text_id, os, os_build,platform, version,build, profile_id, summary, view_state, sponsorship_total, sticky, fixed_in_version, target_version, due_date ) VALUES (4,12,0,0,30,10,100,10,10,10,12,[date-time integer],[date-time integer],10,1,'','','','','',0,'Issue #1 Issue Summary',10,0,0,'','',1);
insert into mantis_custom_field_string_table (field_id, bug_id, value) VALUES (1,1,8);
insert into mantis_custom_field_string_table (field_id, bug_id, value) VALUES (2,1,20);
insert into mantis_custom_field_string_table (field_id, bug_id, value) VALUES (3,1,'Unknown');
insert into mantis_bug_history_table (user_id, bug_id, type, date_modified) VALUES (12,1, 1, [date-time integer]);
with everything except the first line repeated for each issue. This works OK but I'm having a problem with the custom fields, specifically those that are lists. When I go to edit the issue manually in Mantis, the values that I set for the list custom fields are not selected on the page, so when I click "Update information", the information is lost. If I create an issue manually via the UI then the values which I chose on reporting the issue are always selected when I edit the issue. I've tried lookin the the php files to see what is done differently (or additionally) in the manual issue creation but I can't put my finger on it. Anyone know what I'm missing?
Custom fields prob when add issues to Mantis via SQL script
Moderators: Developer, Contributor
Re: Custom fields prob when add issues to Mantis via SQL scr
Ok, I've solved it. There was nothing wrong or missing in the SQL script, it was a stupid mistake I made in defining the custom fields. Where you enter the custom fields, I had wrongly put a space between the possible values, i.e. "1 | 2 | 3" when it should have been "1|2|3". So when I entered an issue manually, of course I selected e.g. "1 ", so when I went to edit the issue, "1 " was selected. However when I entered the issue using the script, it had "1", not "1 ", so the code doing the match on selected values, which I eventually tracked down to cfdef_input_list in cfdef_standard.php, obviously didn't return a match and therefore didn't select the value on the list.