Tidying up tickets

  • Used Zammad version: 6.5.2-1766167336.889983bc.bookworm
  • Used Zammad installation type: .deb package
  • Operating system: Debian 12 bookworm

Both customers and support staff have created a mess with one or the other ticket, i.e. a ticket has been merged wrongly, another one has been split at a wrong place.

Is there any way for an admin (such as myself) to move articles to the correct place?

Thanks in advance!

Hi,
This is only possible via split and merge.

1 Like

OK, bad luck for me. Thank you anyway!

Additional questions:

  1. Can I fix things on database level? I’m almost native speaker of (p)SQL.

  2. Can I remove articles from a ticket, e.g. in case there is a single article in between that is wrong? By UI, API, or psql?

Never, ever, fiddle directly inside Zammads database. Youā€˜re bypassing application hooks and checks. This will cause trouble. Donā€˜t do it. If you have to do it, use the rails console.

As this is a dangerous operation and very advanced, I wonā€˜t share how to do it to protect our copy cats. Sorry.

1 Like

Oh, I see. I’m not used to Rails (we’re a Python shop) at all, so I wouldn’t feel very safe there anyway.

Edit: But there must be some way to delete single articles, right? What am I supposed to do if for some reason an article is in a ticket, that contains information that must be deleted by company policy or by law? Or do I have to delete the complete ticket then? Or split it out and remove the split? No problem, if it is cumbersome, because it does happen not more than once a year :slight_smile:

Deletion of tickets/articles is possible, but dangerous and can break your system - best to create a backup first. This solution is not officially supported by Zammad and it’s often best to just change the ticket’s customer/group to something else, so that only system administrators can see it.

sudo zammad run rails c
Ticket.find(<ticket_id>).articles.pluck(:id, :subject, :created_at) #find article id
article = Ticket::Article.find(12345) #find article
article.attachments.pluck(:id, :filename) #see attachments
article.attachments.each(&:destroy) #delete attachments
article.destroy()
exit
sudo zammad run rake zammad:searchindex:rebuild
1 Like

I see. Maybe it’s not worth to take the risk in my case.
I probably just set the ticket customer to a staff member.
Thanks anyway!

Please do not use .destroy ever. Use delete, other wise you skip triggers from the application which is crucerial. This also spares you from reindexing…

Also if you remove an article, it will remove attachments too.
You are risking data loss with your code. Please, I didn’t share code for a reason. Yours is highly dangerous.

2 Likes

Thanks for your elaboration! I shared the way I deal with this - and it works. I stated the danger that comes with it.
You only said ā€œdon’t do thatā€ but there’s no official process (that i know of) to deal with this situation otherwise. I’d greatly appreciate your expert opinion on how to handle this issue in a more stable and reliable way!

But I did? I said use delete instead of destroy and donā€˜t remove attachments manually…? I gave you an explicit inprovement to lower the danger of your code partly.

2 Likes

Alright, but then you agree that there’s no better way than using my code and switching .destroy with .delete?

That’s what I indirectly said with an earlier reply, yes.
I can’t encourage inexperienced users to do it, still.

1 Like