# Removing the responsible agent when changing the group
This article describes the instructions for removing the assigned agent when changing the group of a ticket.

:::info
Logic:

1. The group change event occurs, a new value for the group appears.

2. If there is a Responsible on the ticket, AND he is not in Offline status, then

    - It is checked whether the Responsible is a member of the new group

        - If not, the responsible is removed and no one is assigned.

        - If he is a member of the new group, then nothing is done.

3. If there is no Responsible or he is in Offline status, then nothing is done.
:::

# Instructions

1. Log in to Swarmica as **Administrator**

2. Create a script in **Settings - Scripts** for the **Administrator** role

![](https://support.swarmica.com/attachments/G/X/GX_t1aeqYEBbFEgB_a/изображение.png)

3. On the page that opens, add the script [trigger_unset_responsible_on_group_change.py](https://support.swarmica.com/attachments/O/v/OvDci32dryfZR-7w_a/trigger_unset_responsible_on_group_change.py)

4. Create an **Event Action (Script)** in **Settings - Event Actions**

![](https://support.swarmica.com/attachments/S/N/SNPEZZBPavUnuzLZ_a/изображение.png)

5. On the page that opens, select the created script (steps 2-3) as the **Action**

6. Add the condition:

```txt
Event type = Ticket group changed
```

7. Change the status to **Enabled** and click **Save**

It should look like this:

![](https://support.swarmica.com/attachments/a/h/ahg3Ev-Ux-U9m7F9_a/изображение.png)

### Problem Diagnosis

You can track the process in the celeryworker container log before running the script:

```bash
docker logs swarmica-celeryworker-1 -f --tail 0
```