Excel report column orders reordering

Title: Excel report column orders reordering

  1. What is your original issue/pain point you want to solve?
    When adding ticket object attributes, the order of columns in the excel report in unreliable

  2. Which are one or two concrete situations where this problem hurts the most?
    We invested time to build excel reports based on some attributes. Adding more attributes should not change the order (new columns should be added at the end of excel report, or we should be able to choose the order) otherwise formulas will break.

  3. Why is it not solvable with the Zammad standard?
    The order in excel report is neither based on ticket object attribute creation order nor creation date, field name or display attribute. The position value would be a logical choice but it does not work either.

  4. What is your expectation/what do you want to achieve?
    We would like new ticket object attributes to appear after old ticket object attributes or we would like to choose the order in the excel export.

If there is any more useful information, feel free to share it all (e.g.: mockup screenshots, if something is UI related, or the API URL/documentation URL for a service you need a connection to).

We could fix this by slightly changing the code at zammad/lib/excel_sheet/ticket.rb at 93f4da17112d495862bdd8ba04fcf3e4362bf88e · zammad/zammad · GitHub

Current code :

    ObjectManager::Attribute
      .where(
        active:        true,
        to_create:     false,
        object_lookup: ObjectLookup.lookup(name: 'Ticket')
      )
      .where.not(
        name:    header.pluck(:name)
      )
      .where.not(
        display: header.pluck(:display)
      )
      .pluck_as_hash(:name, :display, :data_type, :data_option)
      .each { |elem| elem[:width] = 20 }
      .then { |objects| header.concat(objects) }

Fixed code (we added the “.order(:position)” line):

    ObjectManager::Attribute
      .where(
        active:        true,
        to_create:     false,
        object_lookup: ObjectLookup.lookup(name: 'Ticket')
      )
      .where.not(
        name:    header.pluck(:name)
      )
      .where.not(
        display: header.pluck(:display)
      )
      .order(:position)
      .pluck_as_hash(:name, :display, :data_type, :data_option)
      .each { |elem| elem[:width] = 20 }
      .then { |objects| header.concat(objects) }

Your Zammad environment:

  • Average concurrent agent count: 50
  • Average tickets a day: 100
  • What roles/people are involved: Buyers, Hotline

Thank you and have fun.

2 Likes