There are different approaches that you can take, depending on your application.
Essentially you need to
a) Use the insert record behaviour to add the record and assign the unique ID to a session. Do not provide a redirect for this.
b) Use the code i provided above to run using the same trigger as your insert behaviour
c) Redirect to the next stage or page for your application
Cheers
Ian