How to redirect to other record?

I have created a module using module builder,

Say module: XYZ.

Inside XYZ module there is one flex Relate field.

Records inside XYZ modules will be created pragmatically, everytime Flex Relate field will be available with Parent Module and Parent ID.

What I want to do is as follows:

When I open any record in XYZ module, it should redirect to the Parent Record as per Flex Relate Field.