Zammad: Delete tickets via admin interface as job

Created on 19 Oct 2016  ·  28Comments  ·  Source: zammad/zammad

Please make it possible to delete tickets and not just close them. :smile_cat:

feature backlog

Most helpful comment

Hi guys,
i added a new ticket action:

grafik

With this action it should be no problem to clean up your system in future. Please use it carefully, there is no way back and thank you very much for this deep conversation and your support.

Changes are already available in the develop branch.

-Rolf

All 28 comments

Hi @MDXDave - since Zammad is revision-proof this is not an option.

I understand your objection, but at least admins should have the possibility to delete tickets.

As an admin you can use the rails c command on the command line. From there on you can go and do whatever possibilities rails is giving you. Tickets can get deleted via Ticket.find(*id*).destroy. Hope that helps? We do not recommend that.

I know that this is possible with rails, but it would be easier to delete tickets within Zammad. :+1:

At least scheduler should be able to do it.

I think @thorsteneckel decision is right. You should be able to audit old tickets after years so deletion shouldn't be an option at least in the UI. For testing zammad (even a production setup) you should be fine using the rails console which is not hard as well!

I use this function in OTRS to delete spam tickets after 30 days in our spam queue. Sure, one could do this from the command line but its not so comfortable like to do it from the scheduler.

I see your point! We will implement it in the near future. Maybe something like https://github.com/rubysherpas/paranoia is useful in this context.

It's not only about hiding the tickets,it's also about removing the unnecessary stuff from the DB. Currently our spam to ham mail ratio is pretty high, but we detect most of the messages with spamassassin. Nevertheless, email filtering happens after downloading the mails from the POP3, so the tickets have already been created the database and the disk space allocated (speaking of OTRS)
One solution could be to store a reference to the ticket, and replace the content by the information that the ticket has been deleted. So in case of an audit you can prove that the ticket was created, but no longer exists ?

Is there any documentation of how to get in and use the rails console?

I'm currently testing a lot around, and I'd like to get rid of all the tickets "Test1", "Test2", "Test3" etc ;-)

Is there any documentation of how to get in and use the rails console?

shell> rails c
rails> Ticket.destroy_all

If you use the Zammad RPM, you need to do:
shell> zammad run rails c
rails> Ticket.destroy_all

Thanks, works like a charm!

in case you're looking for a way to delete all tickets but some you can use this method:

tickets_to_keep = [1, 2, 3] # enter the ids of all tickets you want to keep
(Ticket.all.pluck(:id) - tickets_to_keep).each { |id| Ticket.find(id).destroy }

this will delete all tickets except Ticket with id 1, 2 and 3

Still no news about it? 😐

Hi guys,
i added a new ticket action:

grafik

With this action it should be no problem to clean up your system in future. Please use it carefully, there is no way back and thank you very much for this deep conversation and your support.

Changes are already available in the develop branch.

-Rolf

Hi,

I tried to use the "delete" action and therefore created a macro to use it. Sadly, it's doing nothing with the ticket, only causing lots of activity in the logs (see below).

I'm using the current develop Debian package 1.6.1-1502058507.b2ece283.jessie

Messages from the log file are like attached when I select the delete macro for one ticket (Id 2394 in this case):

I, [2017-08-07T11:29:50.916731 #20037]  INFO -- : Started PUT "/api/v1/tickets/2934?all=true" for 134.99.182.24 at 2017-08-07 11:29:50 +0200
I, [2017-08-07T11:29:50.928520 #20037]  INFO -- : Processing by TicketsController#update as JSON
I, [2017-08-07T11:29:50.928785 #20037]  INFO -- :   Parameters: {"number"=>"201708077203221", "title"=>"Verzoegerte Mail / Delayed Mail (still being retried)", "group_id"=>"1", "owner_id"=>"9", "customer_id"=>2339, "state_id"=>"4", "priority_id"=>"2", "updated_at"=>"2017-08-07T09:22:04.377Z", "pending_time"=>nil, "id"=>"2934", "all"=>"true", "ticket"=>{"id"=>"2934", "group_id"=>"1", "priority_id"=>"2", "state_id"=>"4", "number"=>"201708077203221", "title"=>"Verzoegerte Mail / Delayed Mail (still being retried)", "owner_id"=>"9", "customer_id"=>2339, "pending_time"=>nil, "updated_at"=>"2017-08-07T09:22:04.377Z"}}
I, [2017-08-07T11:29:51.241498 #20037]  INFO -- : Completed 200 OK in 313ms (Views: 9.1ms | ActiveRecord: 33.0ms)
I, [2017-08-07T11:29:51.263816 #20037]  INFO -- : Started DELETE "/api/v1/ticket_attachment_upload" for 134.99.182.24 at 2017-08-07 11:29:51 +0200
I, [2017-08-07T11:29:51.267849 #20037]  INFO -- : Processing by TicketArticlesController#ticket_attachment_upload_delete as JSON
I, [2017-08-07T11:29:51.267922 #20037]  INFO -- :   Parameters: {"form_id"=>"097621992", "ticket_article"=>{"form_id"=>"097621992"}}
I, [2017-08-07T11:29:51.287497 #20037]  INFO -- : Completed 200 OK in 19ms (Views: 0.3ms | ActiveRecord: 3.5ms)
I, [2017-08-07T11:29:51.817125 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::UserDeviceLogJob (id=15352) RUNNING
I, [2017-08-07T11:29:51.839587 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::UserDeviceLogJob (id=15352) COMPLETED after 0.0222
I, [2017-08-07T11:29:51.844069 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::Ticket::UserTicketCounter::BackgroundJob (id=15353) RUNNING
I, [2017-08-07T11:29:51.853673 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::Ticket::UserTicketCounter::BackgroundJob (id=15353) COMPLETED after 0.0093
I, [2017-08-07T11:29:52.067159 #20037]  INFO -- : Started GET "/api/v1/users/2339?full=true&_=1502091684037" for 134.99.182.24 at 2017-08-07 11:29:52 +0200
I, [2017-08-07T11:29:52.074838 #20037]  INFO -- : Processing by UsersController#show as JSON
I, [2017-08-07T11:29:52.074990 #20037]  INFO -- :   Parameters: {"full"=>"true", "_"=>"1502091684037", "id"=>"2339", "user"=>{}}
I, [2017-08-07T11:29:52.124370 #20037]  INFO -- : Completed 200 OK in 49ms (Views: 9.2ms | ActiveRecord: 5.2ms)
I, [2017-08-07T11:29:52.162360 #20037]  INFO -- : Started GET "/api/v1/ticket_customer?customer_id=2339&_=1502091684038" for 134.99.182.24 at 2017-08-07 11:29:52 +0200
I, [2017-08-07T11:29:52.171857 #20037]  INFO -- : Processing by TicketsController#ticket_customer as JSON
I, [2017-08-07T11:29:52.172077 #20037]  INFO -- :   Parameters: {"customer_id"=>"2339", "_"=>"1502091684038", "ticket"=>{}}
I, [2017-08-07T11:29:52.269458 #20037]  INFO -- : Completed 200 OK in 97ms (Views: 30.2ms | ActiveRecord: 4.1ms)
I, [2017-08-07T11:29:53.149049 #20037]  INFO -- : Started GET "/api/v1/users/2339?full=true&_=1502087532475" for 134.99.182.76 at 2017-08-07 11:29:53 +0200
I, [2017-08-07T11:29:53.158434 #20037]  INFO -- : Processing by UsersController#show as JSON
I, [2017-08-07T11:29:53.158857 #20037]  INFO -- :   Parameters: {"full"=>"true", "_"=>"1502087532475", "id"=>"2339", "user"=>{}}
I, [2017-08-07T11:29:53.227291 #20037]  INFO -- : Completed 200 OK in 68ms (Views: 13.2ms | ActiveRecord: 3.8ms)
I, [2017-08-07T11:29:53.424242 #20037]  INFO -- : Started PUT "/api/v1/taskbar/74" for 134.99.182.24 at 2017-08-07 11:29:53 +0200
I, [2017-08-07T11:29:53.434444 #20037]  INFO -- : Processing by TaskbarController#update as JSON
I, [2017-08-07T11:29:53.434747 #20037]  INFO -- :   Parameters: {"key"=>"Ticket-2934", "client_id"=>"123", "callback"=>"TicketZoom", "state"=>{"ticket"=>{}, "article"=>{}}, "params"=>{"ticket_id"=>2934, "overview_id"=>2, "shown"=>true}, "prio"=>16, "notify"=>false, "active"=>true, "updated_at"=>"2017-08-07T09:19:33.085Z", "id"=>"74", "taskbar"=>{"id"=>"74", "client_id"=>"123", "key"=>"Ticket-2934", "callback"=>"TicketZoom", "state"=>{"ticket"=>{}, "article"=>{}}, "params"=>{"ticket_id"=>2934, "overview_id"=>2, "shown"=>true}, "prio"=>16, "notify"=>false, "active"=>true, "updated_at"=>"2017-08-07T09:19:33.085Z"}}
I, [2017-08-07T11:29:53.500058 #20037]  INFO -- : Completed 200 OK in 65ms (Views: 1.4ms | ActiveRecord: 3.2ms)
I, [2017-08-07T11:29:54.323682 #20037]  INFO -- : Started GET "/api/v1/ticket_overviews?_=1502091684039" for 134.99.182.24 at 2017-08-07 11:29:54 +0200
I, [2017-08-07T11:29:54.324343 #20037]  INFO -- : Started GET "/api/v1/ticket_overviews?view=all_unassigned&_=1502091684040" for 134.99.182.24 at 2017-08-07 11:29:54 +0200
I, [2017-08-07T11:29:54.331526 #20037]  INFO -- : Processing by TicketOverviewsController#show as JSON
I, [2017-08-07T11:29:54.336974 #20037]  INFO -- : Processing by TicketOverviewsController#show as JSON
I, [2017-08-07T11:29:54.337380 #20037]  INFO -- :   Parameters: {"view"=>"all_unassigned", "_"=>"1502091684040", "ticket_overview"=>{}}
I, [2017-08-07T11:29:54.337205 #20037]  INFO -- :   Parameters: {"_"=>"1502091684039", "ticket_overview"=>{}}
I, [2017-08-07T11:29:54.519933 #20037]  INFO -- : Completed 200 OK in 181ms (Views: 0.8ms | ActiveRecord: 78.1ms)

@rolfschmidt Is your delete action already available in the latest official Zammad2? I can't find it.
I'm using:

# apt policy zammad
zammad:
  Installed: 2.1.0-1509936117.b8f98730.xenial
  Candidate: 2.1.0-1509936117.b8f98730.xenial
  Version table:
 *** 2.1.0-1509936117.b8f98730.xenial 500
        500 https://dl.packager.io/srv/deb/zammad/zammad/stable/ubuntu 16.04/main amd64 Packages
        100 /var/lib/dpkg/status

Hey guys,

@strangechoice : yes this was a mistake. The delete action will be only supported in the scheduler. We removed the action from the macros.

@passboltUser : Please take a look at the scheduler.

grafik

Best regards,
Rolf

@rolfschmidt Thanks. Unfortunately I can't get it running, don't see the New Scheduler. I'm under /#manage/time_accounting.

zammad

Hello @passboltUser ,
i think you just missclicked.

  • Click on the menu Scheduler
  • Then on the top right on New scheduler
  • Below you choose the time where the tickets should get deleted.
  • Below you choose the conditions for the deletion of the tickets
  • Below you see some example tickets which will get deleted
  • Below you see the action you can do on the tickets. Here you can choose Action -> Delete

grafik

Best regards,


Hallo @passboltUser ,
ich glaube du hast dich nur verklickt.

  • Klick mal auf Automatisierungen
  • Dann rechts oben auf Neue zeitgesteuerte Aktion
  • Dann wählst du als erstes den Zeitpunkt aus wann die Tickets immer gelöscht werden
  • Darunter die Bedingungen die ein Ticket erhalten muss damit es gelöscht wird
  • Darunter sieht man einen Ausschnitt der Liste der Tickets die dann gelöscht wird.
  • Und darunter sieht man die Aktion, welche bei den Tickets ausgeführt werden soll. Hier wählst du dann
    Aktion -> Löschen aus.

grafik

Gruß

@rolfschmidt Danke, habs gefunden. So werden alle bestimmten Tickets gelöscht? Kann man auch einzelne löschen? Wir haben geschlossene Tickets die wir mit einem Tutorial tag getaggt haben, um nachzugucken, wie mal ein Problem gelöst wurde (und diese Tickets können dann in einer benutzerdefinierten Ansicht praktisch als alle Tutorials angezeigt werden).

Added eng: Thanks, found it. But this way all tickets are doing to be deleted? It it possible to delete individual ones? We have closed tickets which we tagged 'Tutorial' to lookup later how a problem was once solved (these tickes can be displayed nicely in a self-created view).

Hi @passboltUser ,
if you choose the right conditions it should.

I'm sorry guys, i added the english translation for my last post. We should write english here on the issue tracker.

Ok, thanks, I'll try. (also added english translation)

Thanks, it works 👍 I added a second condition where I filtered by tickets which contain the tag "Spam" (so one has to add the tag "Spam" to such tickets).

First, i am happy to be able to delete tickets that creates loops - like tickets out techs sent to wrong email address of the client and the NDR keeps returning as we try to close the ticket since there is a close notification...

The problem we face is having a batch of 30 different numbered tickets that has loops or other issues that we want to delete and the schedule way is a way to learn what is patience... one manually entered ticket number for every 5 minutes...

My 2c is that there should be an admin-only, password protected form to delete tickets directly at the web interface.

I think i have found a nice solution with the great genius tools Zammad has to offer but it is not working for some reason :)
I used "Objects" at the System section of settings to create a new text field for tickets, called it "to be deleted by admin" and default text: "Please enter code".
Updated database and restartde Zammad.
Now that i have this new field, i can schedule deletion by it so i went to scheduler and created a new schedule with a condition that the "to be deleted by admin" field must contain the words for example: "delete me now!".

Now all i have to do is find the tickets i want to delete and enter this text string at the new field i have created.

image

The problem is it does not work (not deleting tickets) :)

Another option to accomplish deletion of many tickets without the need to wait for the schedule timer is to have a "run now" button for the scheduler :)

Hi @DjMagicFingers ,
i added a object with the name "to_be_deleted_by_admin" as a input field and set some tickets with the value "delete me please". Afterwards i added a scheduler job to remove them. Works for me. It looks like you did not fill the values correctly at the ticket, because else they would show up in the preview in the screenshot you pasted. Could you please check again? Which version of zammad are you using?

Best regards,
Rolf

This is already part of Zammad and has been adressed with: https://github.com/zammad/zammad/commit/7d2409bddcbeaa0d400c6deb7012cec97ee53008

Was this page helpful?
0 / 5 - 0 ratings