Custom logic create

Good morning,
I want to run some custom logic, when I insert a record via the cms, and want to update the record when I create it.
So relying on Controllers | Strapi Documentation I have this little snippet in
…/api/hz/controllers/hz.js:

const { createCoreController } = require(‘@strapi/strapi’).factories
module.exports = createCoreController(‘api::hz.hz’, ({ strapi }) => ({
async create(ctx) {
const response = await super.create(ctx)
if (response && response.hz) {
const hzValue = response.hz
const hzlValue = hzValue.length
await strapi.query(‘hz’).update(
{ id: response.id },
{ hzl: hzlValue }
)
}
return response
}
}))

Well, it does not work.
The thing is, the entry is created, and it is also created when I comment out the whole method create …
So it seems it is not called at all, bt sth else is going on.

Anyone has any hint, what I am doing wrong?

- Strapi Version: 4.14.0-alpha.0 (node v)

1 Like

Hi!
I have the same problem…
did you manage to solve it?