Move all Tickets from one customer (user) to an other customer

Infos:

  • Used Zammad version: 6.4.0-1732871355.611ba7e2.bullseye
  • Used Zammad installation type: package
  • Operating system: Debian GNU/Linux 11 (bullseye)
  • Browser + version: Firefox 128.5.0 esr

Actual behavior:

I need to move the tickets from one customer (user) to another. I can do this manually for each individual ticket, but if there are over 100 tickets, then it’s too much manual work for me. Is there another way?

Expected behavior:

I would like something like that.

GET new_customer id Where Email = new_cust_email;
Get old_customer id Where Email = old_cust_email;

Update all Tickets Set CustomerID = new_customer_id Where Customer_id = old_customerid

How could this be done with Zammad.
Thanks for Help

You can create an overview for only this “user”. Than create a macro, which changes the user to the new user.
In the overview you can select all tickets and start the macro by draggin the tickets to the top and all macros should show up.
If i remember correctly, you will get a list of 50 (or was it 100?) tickets in the overview. So you will have to do the task more than once. But it’s not for every single ticket.
Hope that helps.

Maybe you could check the automations for that.

Hi,

in Rails console you can do:

cid = Ticket.find_by(number:‘20240620110130’).customer_id
So this is customer_id e.g. 15685.
Ticket.where(customer_id:‘15685’).count
Just to know how much tickets the customer has. Now you can do:
Ticket.where(customer_id:‘15685’).update_all(customer_id: 1)

Perhaps that helps. But I also like the macro solution.

Cheers Guido

Thanks for your input.
I solved my problem with a macro, but GTR’s approach looks interesting, I’ll try it next time

update_all skips important rails triggers that are required for certain things. This may draw e.g. the searchindex inacurate. Also, user ID 1 is system.

So if we provide rails console commands for that, you’d rather find the users you want to find via User.find_by(email: 'email@domain.tld').id

1 Like

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