Auto populate Customer Id field before save in Serenity Platform

295 views Asked by At

I am doing project using serenity platform and I have this scenario. I want to auto populate customer id field before save. It will contain 3 letter prefix "CUS" + auto increment number which will be the max Id from customer table + 1. Any idea how i can implement this?

Thank you in advance

1

There are 1 answers

0
John Ranger On

your approach to calculate the next ID is very dangerous if more than one user will be using your project concurrently.

Why not doing this in the AfterSave overridable method in xyzRepository.cs. There you have read access to the just generated correct ID for this new record. And there you can do a direct update to this new record, setting the "CUSxyz" value.

Regards,

John