Dynamic hook onAfterCreate not working

I want to have a trigger when a record is created to update his createdAt field. I tried the example from your docs and nothing happens when record (node) i created.

Function: setCreatedAt (javascript)

var now = new Date();
doc.field("createdAt", 123123);
print('\\nTest test: ' + doc.field('createdAt'))
doc.save();
return;

SQL commands

ALTER CLASS FlexiTime SUPERCLASS +OTriggered
ALTER CLASS FlexiTime CUSTOM onAfterCreate=setCreatedAt

After adding some records, nothing happens. Hook is never triggered.

DB version: 3.0.21