Custom Multiselect Object/Attribute Shows Key Name in Excel Report

Infos:

  • Used Zammad version: 5.1.0-1649253418.8274bb8a.centos8
  • Used Zammad installation type: package
  • Operating system: CentOS 8
  • Browser + version: Firefox 98.0.2

Expected behavior:

  • Generated .xls reports should show the “Display” name for custom multiselect attributes/objects.

Actual behavior:

  • Generated .xls reports show the “Key” name for custom multiselect attributes/objects.
  • See attached images.

Steps to reproduce the behavior:

  • Reporting > Download x Record(s)
  • The custom multiselect attribute in the downloaded .xls will show the “Key” name, not the “Display” name.

@Isaac You got MultiSelect fields to work ?

I created one and tried to use it on my tickets and it errors out when creating a ticket. I get a dark box with a red X stating Invalid Valaue ‘[“2”,“3”,“4”]’ for field test1 (see below)

Did you do anything special to make it work ?

I managed to solve this problem by editing the source code. Below are the steps I took.

  1. Open /opt/zammad/lib/excel_sheet.rb

  2. Remove the following if statement from value_lookup:

if value.is_a?(Array)
  value = value.join(',')
end
  1. Replace the first when block in value_convert with this when block:
when 'boolean', %r{^(multi|tree_)?select$}
  if object[:data_option].present? && object[:data_option]['options'].present?
    if value.is_a?(Array)
      displays = []
      value.each do |key|
        displays.push(ObjectManager::Attribute.data_options_hash(object[:data_option]['options'])[key])
      end
      value = displays.join(',')
    else
      value = ObjectManager::Attribute.data_options_hash(object[:data_option]['options'])[value]
    end
  end
  @worksheet.write_string(@current_row, @current_column, value) if value.present?
  1. Restart zammad:

systemctl restart zammad

Zammad creates an array of Keys. Then it turns that array into a comma-separated string of keys (step 2 prevents this). Then it tries to get the Display value of that comma-separated string of Keys. It should try to get the Display value of each Key individually.

The code in step 3 retrieves the Display value of each Key, then joins those values into a comma-separated string.


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.