How to recognize when Add/Edit in "Before model save" section

I need help with recognizing when new record is being added and when edited. Becase a have some logic for editing and i need some other logic for saving.

Generally, you can use the property ‘ver’, that means version. When you are creating a new record, the doo.model.ver is always -1. Just after you save your new record, the version changes to 0, to indicate that it is a new existing, saved record that has not been edited yet. And with every new change to the record (after saving, of course), the number gets higher by 1.
So if you need to condition some behaviour when saving your record based on whether it is a newly created record or an edited record, you can use the condition
if (doo.model.ver === -1) {do something for new record} else {do something else for editing existing record}.
I hope this helps you.

Thank you Anna, that exactly what i needed :slight_smile: