# "Sorry, An error has occurred" when changing a badge sql trigger to "When a user is edited or created"

**URL:** <https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061>\
**Category:** Bug\
**Created:** [21.Май.2015 07:46:32 UTC](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061 "2015-05-21T07:46:32Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [21.Май.2015 10:16:37 UTC](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061/9 "2015-05-21T10:16:37Z")

</div>

Almost.

```plaintext
    SELECT cf.user_id user_id, cf.updated_at granted_at
    FROM user_custom_fields cf u
    WHERE cf.name = 'user_field_1'
    AND (
      cf.user_id IN (:user_ids)
      OR :backfill
    )
    AND length(cf.value) > 1

```

---

_[View the full topic](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061)._
