I’m not sure what your objective is doing things complicated which can be done simply?
Any data field in a transaction class which has the rand keyword at the beginning of the declaration will be automatically randomized when you call the randomize method on the class object. If you want to take influence on the randomization you can do this by passing constraint to this data field or switching of the randomizaion of this data field.