Run server script only on first save/on create

Is there a way to run a script only if the document is not yet in the database? ie. when it’s being created?

Thanks

You can validate against frm.is_new()

Hey thanks! For anyone reading this, I used before_insert() however it seems like is_new() should be a cleaner and more verbose solution.