diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 639cf46b3..7acee13db 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -480,7 +480,10 @@ class CaseLog < ApplicationRecord def self.order_csv_attributes(initial_attributes) attributes = initial_attributes.clone - ordered_default_form_questions = move_checkbox_answer_options(FormHandler.instance.forms.first.second.questions) + downloaded_form_years = all.map(&:collection_start_year).uniq.compact + + downloaded_form_fields = if downloaded_form_years.count == 1 && downloaded_form_years[0].present? ? FormHandler.instance.get_form("#{downloaded_form_years[0]}_#{downloaded_form_years[0] + 1}").questions : FormHandler.instance.forms.first.second.questions + ordered_default_form_questions = move_checkbox_answer_options(downloaded_form_fields) attributes = (ordered_default_form_questions & attributes) + (attributes - ordered_default_form_questions) attributes = move_metadata_fields_to_front(attributes)