# Problems with editing recipient groups of CiviMail

Sometimes I cannot remove a group from recipient list of a Mailing. This can happen for instance when I re-use a mailing, but I want to change the group – I can add a new one, but clicking "x" on the old one just triggers "Estimating" label for a while and does not do anything.

Here I cannot remove "Replay" group:

After clicking "Next>", I see the recipient group appearing several times (see attached pictures).

How can I debug this? I wasn't able to reproduce this on demo.civicrm.org.

I'm using CiviCRM 4.6.4 with CiviMail 1.0.

edit: I have done some more tests with CiviCRM 4.6.5, where this bug persists.

As I click through all the "new mailing" fields, there are numerous AJAX calls to https://apps.akcjademokracja.pl/crm/civicrm/ajax/rest with entity=Mailing, action=create API call, with json similar to:

"{"id":"23","domain_id":"1","header_id":"1","footer_id":"2","reply_id":"8","unsubscribe_id":"5","resubscribe_id":"6","optout_id":"7","mailing_type":"standalone","from_name":"Akcja+Demokracja","from_email":"kontakt@akcjademokracja.pl","url_tracking":"1","forward_replies":"0","auto_responder":"0","open_tracking":"1","override_verp":"1","created_id":"2","created_date":"2015-08-04+13:22:01","scheduled_date":"2015-08-04+13:22:00","approver_id":"2","approval_date":"2015-08-04+13:22:01","is_archived":"0","visibility":"Public+Pages","dedupe_email":"0","email_selection_method":"automatic","is_error":0,"jobs":{},"groups":{"include":[6],"exclude":[],"base":[]},"mailings":{"include":[],"exclude":[]},"name":"placeholder","subject":"placeholder","options":{"force_rollback":1},"api.mailing_job.create":1,"api.MailingRecipients.getcount":{"mailing_id":"\$value.id"}}" 

as you see, AJAX properly sets "groups":{"include":[6],"exclude":[],"base":[]} but in the database I see more and more civicrm_mailing_group entries:

mysql> select * from civicrm_mailing_group where mailing_id = 23 ; +------+------------+------------+---------------+-----------+-----------+-------------+ | id | mailing_id | group_type | entity_table | entity_id | search_id | search_args | +------+------------+------------+---------------+-----------+-----------+-------------+ | 5596 | 23 | include | civicrm_group | 6 | NULL | NULL | | 5597 | 23 | include | civicrm_group | 6 | NULL | NULL | | 5598 | 23 | include | civicrm_group | 6 | NULL | NULL | +------+------------+------------+---------------+-----------+-----------+-------------+ 3 rows in set (0.00 sec) 

Perhaps then, it's a civicrm schema issue – it should force Uniqueness in the table? Or is it rather a backend issue?

• I wonder if the group was initially in there more than once. Does this only happen when you re-use an old mailing from before your 4.6 upgrade? – Coleman Jul 7 '15 at 17:51
• Thank you for questions – I discovered some logic in this: This also happens, when I save the Mailing as a draft. When I re-open it, the group is added 3 times. If I click [x] on the list to remove it three times, it gets removed finally. But when I add it again once, and save the Mailing and reopen it again, the group is added 6 times! This is a fresh 4.6.4 install. – movonw Jul 8 '15 at 9:42
• could you open your browser debugger (eg. firebug) and check what are the ajax network calls- eg, called once or several time? I don't have the issue, not sure if it's because something on your server or because of the non native english – Xavier Jul 20 '15 at 10:02
• @Xavier yes, I'll edit the first post – movonw Aug 4 '15 at 11:28
• @movonw, not sure why you would get this issue. The only suggestions:1) upgrade to the latest stable version, clear caches, logout/in and see if the problem persists. 2) try to switch the language to en us (just to eliminate that option) – Xavier Aug 5 '15 at 11:50