UDF: How to get record size berofe creating it

There is an option to get record size via UDF using record.device_size(). However it works only for records, that are already created and stored in AE. Is there a way to calculate record_size in UDF before creating record (e.g. before calling aerospike:create(rec))?

You can estimate the size based on the constituents of a record, but you may not know the exact size until you create one. There are a couple of older posts that talk to this issue here and here. Please also look at the useful info in the capacity planning page.