Generally speaking, the ID should be generated by the database, which is done when you save the record. You can then report the value to the user, if appropriate, after the registration is complete. Doing it any other way causes issues, e.g. if someone starts to register and then doesn't complete it or multiple people register at the same time.