Choice codes can be viewed and updated using the bulk export/import workflow. This lets you see what codes are currently assigned and update them in bulk - without having to touch each question individually.
Viewing codes via bulk export
Open your survey in authoring
Go to Bulk Export
Download the export file
The export file includes two new columns at the end:
Column | What it shows |
Code | The current code for this item. Blank if no code has been set yet (system will assign one at publish). |
Code_editable | Yes = you can change this code. No = this item is published and its code is locked. |
The export includes rows for choices (single and multiple choice questions), grid answers, and grid statements.
Setting codes via bulk import
Step 1 - Export your survey
Download the bulk export file. This gives you the current state of all choices, statements, and answers with their existing codes and editability status.
Step 2 - Fill in your codes
In the Code column, enter the code you want to assign to each item. A few rules:
Codes must be whole numbers between 1 and 99999
Codes must be unique within each code space - choices of the same question can't share a code, grid answers can't share a code within their grid, and grid statements can't share a code within their grid
Grid statement and answer codes are independent from each other - the same number can exist in both
Leave a cell blank if you don't want to change that item's code
The Code_editable column is ignored if present - you don't need to remove it
The Code column is optional - if not included, no codes are changed
Step 3 - Import the file
Upload your updated file via Bulk Import. Rival will validate all codes before applying any changes.
Step 4 - Review any errors
If validation fails, you'll receive an error file clearly listing which question and item has an issue. Fix the errors and re-import.
Validation rules
Scenario | Result |
Code is not a whole number, is a decimal, or is outside 1–99999 | Error: "Invalid value for code" |
Two items in the same code space have the same code in the import | Error: "Code [X] is used more than once. Codes must be unique within [choices/statements/answers]." |
Trying to change the code of a published item | Error: "Cannot modify codes for published [choices/statements/answers]" |
Importing the same code that a published item already has | Ignored - no error |
Trying to use a code that belonged to a deleted published item | Error: "Code [X] is assigned to a deleted [choice/statement/answer] and cannot be reassigned" |
Blank value for an item | No change - the item keeps whatever code it currently has |
Swapping two codes (e.g. Choice A: 1→2, Choice B: 2→1 in the same import) | Supported - validation checks the final state, not row by row |
Assigning a code already in use by another item in a separate import | Error: duplicate code detected |
Grid questions
Grid answers and grid statements both support custom codes and follow the same rules as choices. You can assign codes to statements and answers independently via bulk import, and they're locked at publish.
The exports dictionary and data file column names reflect actual codes - so Single_Choice_Grid_1_5 means the statement with code 5, and Multiple_Choice_Grid_1_5_3 means statement code 5, answer code 3. This makes data combination for grid questions just as reliable as for choices.
Masked items
If your question includes masked choices, statements, or answers (items pulled in from another question), those masked items also appear in the export file. Their Field_type column will show Masked choice (source question name) so you can identify them.
You can assign codes to masked items just like regular items. The codes are independent - a masked item can have a different code in this question than it has in the source question.
Note: If you include item text for a masked item in your import, it will be silently ignored. Text for masked items can only be updated in the original source question.
What happens at preview?
When you preview your survey, Rival shows you what codes will be assigned to each item. For items you haven't set a code for, Rival calculates a temporary code using the gap-filling algorithm. These preview codes are not saved - they're just for reference. Codes are only permanently saved when you publish.
What happens at publish?
When you publish a question:
Items with codes you've set keep those codes - they're saved as-is
Items without a code are assigned one automatically using the gap-filling algorithm
All codes are permanently locked - they cannot be changed after publish
