Unable to delete a Question Choice from a Multiple Choice variable

ewilks
Giga Expert

We have a Multiple Choice Question with 5 options.   I have been asked to delete one of those choices (there is no Active field, so I can't set it to inactive).   So I go into the variable, select the Question Choice that I want to delete, slide to the bottom and from the "Actions on Selected Rows..." dropdown I choose "Delete".   It pops up the confirmation box (see attached screenshot) and I click the Delete button.   But the question choice isn't deleted.   I've tried to do it by opening the Question Choice and clicking the delete button at the top of the form and it still won't delete. Does anyone know how I can remove this question choice?Delete_option.JPG

1 ACCEPTED SOLUTION

Hi Eric,



I ran into this issue after upgrading to Fuji.   What I found is that on the Question Choice[question_choice] table any choices that existed before the upgrade had no Class[sys_class_name]. What was happening when the class was null is that the SQL says Delete this record from NULL, which obviously doesn't work.   Here is a background script that I ran to set the Class, which then allows the records to be deleted.



var count = 0;


var grQuestion = new GlideRecord('question_choice');


grQuestion.addQuery('sys_class_name', '');


grQuestion.query();



while (grQuestion.next()) {


  grQuestion.sys_class_name = 'question_choice';


  grQuestion.update();


  count++;


}



gs.log("Questions updated: " + count);



Enjoy!


-Robert Chrystie


CareWorks Technologies


View solution in original post

7 REPLIES 7

Victor Ruiz
Tera Guru

Try deleting it from the question_choices table.


Thanks Victor.   It seemed like a great idea.   But it still won't allow me to delete it.   I even tried elevating privileges first


Hi Eric,



I ran into this issue after upgrading to Fuji.   What I found is that on the Question Choice[question_choice] table any choices that existed before the upgrade had no Class[sys_class_name]. What was happening when the class was null is that the SQL says Delete this record from NULL, which obviously doesn't work.   Here is a background script that I ran to set the Class, which then allows the records to be deleted.



var count = 0;


var grQuestion = new GlideRecord('question_choice');


grQuestion.addQuery('sys_class_name', '');


grQuestion.query();



while (grQuestion.next()) {


  grQuestion.sys_class_name = 'question_choice';


  grQuestion.update();


  count++;


}



gs.log("Questions updated: " + count);



Enjoy!


-Robert Chrystie


CareWorks Technologies



Thanks Robert.   I got a similar script from HI, but forgot to update this.