Calculation problem when switch from servoy seq to db indent

We switch from servoy_sequence to db indentity and now all our calculated fields which use a primary key value stop working.
When we create a new record and pk sequence setup as db indent y Servoy return a value of pk ,like DbIdentValue30278025. Only when we apply databasemanager.Savedata() the returned value converted to actual integer number. All calculations suppose to be done before Savedata().
I try to move calculation to database entity and use trigger afterRecordInsert. I can see that it possible to change a value on the record in this method but fields never updated in database.
function afterRecordInsert(record) {
record.log_data = attribute_id.toString()
application.output(log_data)
databaseManager.saveData(record);
}

With Servoy sequence we don’t have this problem, because we can use a actual value of PK.
How to define a actual value of PK with db indentity sequence and if somebody have any idea why a afterInsert trigger not updating database.

if you use db_ident (so keys are generated on insert) then your calc can only work on them when the record is inserted
So it can never work before saveData()

Use servoy_seeq or db_seq for that. So that you know the pk field beforehand, before you do saveData()

about saveData: thats not fully sure, if you just do saveData() then it should be fully saved.
Doing saveData() in a onafterXxx doesn’t do much, because you are already in a saveData()

what is the exact first saveData() call that you do, is that with the record as argument?
(because that could be the tricky part, then we really only save the record and we don’t try to save everything that the onafters trigger again)

Thanks, I solve a problem by using a trigger directly on the database(afterinsert).
We created a text fields on each table in database which used format as in Servoy audit trail table (pk_data in log file) in order to use relations. Our audit trail form build directly on the log file(tableview) and to make fields readable (not show a primary key) we use relations and replace a PK by company name or Person id by Person Name…, for example . Our providers on the form is calculated fields and it’s seems only thought relation we can extract right information. I try to use find method in calculated fields and it not works.
So, before when we used dbseq we used calculated fields in tables which saved a primary key in format as servoy use in log file. Now, with db indentity we don’t know a pk until it will saved in database. We setup trigger in database and it works.
I found that trigger in Servoy not works If we updating related records in afterrecordinsert (on the database entity level).If record not related it seems no problem.