After a project has collected real data, you may encounter a scenario where you want to prevent a response choice from being seen or selected.
Consider a project where the team interviews participants on the phone, and they want to track which team member is conducting the appointment. They may have a field with a list of staff names to select.
It's normal that team members may come and go over the course of the project's lifecycle. Let’s say that John Doe is no longer an interviewer. We don't want "John Doe" to be an option anymore, but we do want to keep track of cases where “John Doe” was selected as interviewer in the past.
To keep this data, you should not erase the "John Doe" response option.
Erasing the option entirely will result in data loss for that response option. This would mean that all records that have “2, John Doe” selected before the change would appear blank, as if no response had been selected.
Instead, you may wish to keep the option "John Doe" so that you do not lose the data. To do this, start by selecting the Action Tags/Field Annotation box in your field editor.
Within the trigger pop-up window, labeled “Logic editor”, write the syntax below.
@HIDECHOICE=""
The @HIDECHOICE action tag will follow the pattern below, where “x” is replaced by the raw value associated with the response choice you would like to hide.
@HIDECHOICE="x"
In this example, the raw value for "John Doe" is "2".
Therefore, we can hide the “2, John Doe” response option with the syntax written below.
@HIDECHOICE="2"
Now, the response choice for "John Doe" does not appear to be an option on forms where it hasn't been selected.
However, on previous forms where it was selected, you will still see the response option selected, and it will remain available unless another option is saved.
To hide multiple response options, specify the raw value of each choice you would like to hide, separating them with commas, and enclosing these values in a set of quotation marks. Your syntax should follow the format below.
@HIDECHOICE="x,y,z"
Returning to the interviewer example, let's say we want to hide "John Doe", "Han Solo", and "Tony Soprano". We would first identify the raw values associated with each interviewer name.
Then, write the @HIDECHOICE statement to reference these values.
@HIDECHOICE="2,4,5"
In some cases, it may make more sense to show a select list of choices rather than hide a list of choices. For example, if you have a list of 40 response options, and you only wish to display 3 of them, then you may opt to use @SHOWCHOICE instead.
For example, to only display “2, John Doe”, the following syntax can be used.
@SHOWCHOICE="2"
Now, if no other option has been selected, only the option "2, John Doe" will appear in the dropdown.
If another option was originally selected, you will still see the response option selected, and it will remain available unless another option is saved.
IMPORTANT NOTE: @HIDECHOICE and @SHOWCHOICE can only be used on radio, dropdown, or checkbox fields.
You may refer to the REDCap “Action Tags” documentation in REDCap for additional information on these action tags. This is accessible by clicking the red “Action Tags” button anywhere it appears in REDCap.