Hi,
I want to remove all the questions and response scales from my application and import a new set of defined properties. When I try to delete the current questions or response scales I get the following error:
*This Question cannot be deleted because: *
Can’t delete questions that have answers.
Where can I manage the answers given to these questions? And will it be possible to delete these “old” questions?
@Kimberley, morning! The system makes sure that you won’t have answers linked to the questions that don’t exist anymore. So first you need to clean up answers table and then - delete questions.
@k.molokova Thank you. But the thing is, I can’t find the “answer table”. I have found the response scales, but not the actual answers to the questions. Could you tell me where to find it and how to clean it up?
@Kimberley, you can find Answers table (grid) within Overviews, but this grid doesn’t have the “Delete” button, so you can use a scheduled task to delete Answer records.
-
First decide which answers are linked to the question(s) you want to delete: go to the Overviews (1) > Answers grid (2) > add a column with id of the linked question (3):
-
Then make sure you have a process for deleting records: Settings (1) > process action definitions (2) > add a new > choose a process “delete_recordscontrollercomponent” (3) > save and determine params and return values (4) > they must be visible after the determonation:
-
Then create a scheduled task: Settings > scheduled tasks (1) > add a new > check the scheduling service (2) > set a schedule (3) > go to the process (4):
-
Inside the process (1) > set a value (process) to the “Delete helper” (delete process) you have just defined (2) > update parameters (3):
-
Check the process arguments: set which records you want to delete (1) > in my example I wanted to delete answers related to the questions with the id = 3 (2) > set interactive = false (3) > set auto_delete_all_casccades = true (4):
-
Go back to the scheduled task > click on the “Register” button (1) > as soon as 2 new buttons will appear (“Deregister” and “Run now”) > click on the “Run now” (2):
-
Check the Anwers grid > the answer records you filtered in the scheduled task must be removed.
-
Now you can go back to the Questions grid and delete a question with id you used for filtering answers.
If you want to delete all questions > you need to delete all answers where the question is not null. Frequently used expressions (for filtering too) are here:
Expressions: Frequently Used Functions
1 Like
@k.molokova Thank you for the clear explanation. This fixed it
1 Like
@Kimberley, we with @Helena have found one more way to delete answers for question(s) > via exporting/importing answers table:
- You need to create an export definition (1) with the embedded import definition = custom (2) and data set = answers (3) filtered by question (4) you want to remove. After saving this export definition you will see “Generate import definitions” button > click on it > import definitions will appear in the grid below (5).
Export answers table.
-
Go to this import definition > set “Don’t add new records” = true (2) > go through the field (3) and empty them (BUT keep the GUID field, it is our key value (7)). To empty field > set “Use advanced expression” = true (4) and “Allow null value” = true (5) and advanced target expression = null (6) via the getnull() expression.
-
Validator will help you with the type that is wanted in the advance target expression field (1). Then remove source field (2).
-
Create an import record > set mode = import with an embedded definition and attach the file with answers you have just exported. Click import. The anwers will be emptied, and you can remove the question you wanted.