How Can I add a new Ticket State

Hello, I would like to add a status “in progress” when the ticket is being treated. I tried the codes proposed by the doc"Working with ticket information — Zammad documentation" but it does not work ^^. Someone to help me please :slight_smile:

Thank you

Amir

Hi,

open the rails console:

sudo zammad run rails c

copy that in your console and enter:

Ticket::State.create_or_update(
    name: 'in progress',
    state_type: Ticket::StateType.find_by(name: 'open'),
    created_by_id: 1,
    updated_by_id: 1,
  )

and after that, copy that in your console and enter:

attribute = ObjectManager::Attribute.get(
    object: 'Ticket',
    name: 'state_id',
  )
attribute.data_option[:filter] = Ticket::State.by_category(:viewable).pluck(:id)
attribute.screens[:create_middle]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_new).pluck(:id)
attribute.screens[:create_middle]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_new).pluck(:id)
attribute.screens[:edit]['ticket.agent'][:filter] = Ticket::State.by_category(:viewable_agent_edit).pluck(:id)
attribute.screens[:edit]['ticket.customer'][:filter] = Ticket::State.by_category(:viewable_customer_edit).pluck(:id)
attribute.save!#

After that its done. The new stat will appear shortly after its done.

– Tested with Zammad V5 –

Greets

Virtex

Could you please clarify what doesn’t work?

Error messages as example?
What’s your Zammad version?

Hi Virtex.
Thanks for your feedback. It’s working. Can you also tell me how to delete a state please :slight_smile:

Amir

Please rather update the state to inactive.
Removing referenced states will be an issue, if creation brought issues to you already, you may want to play safe.

Ticket.find_by(name: '<my amazing name>').update(active: false)

Don’t forget to run the attribute update command which is mandatory.
Please note that setting default states to inactive or removing them may™ brick your system depending on the state.

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