Unique Enquiry Reference on Form Submission

Hello

I am building a form into our website - that upon submission via the button, needs to provide the person submitting the form with a unique reference. This unique reference also needs to be included in the automation email they receive. Much like how when you place an order you get an order reference.

I have spent hours searching for an answer and am truly stumped.

Any help/guidance please?

Thank you