Generating membership numbers for contacts

Question:
Is there a way to write Velo code within an automation that generates a unique membership number for a contact when that contact is moved in a workflow or similar?

I don’t know enough about javascript and Wix to figure this out and would appreciate any help or tips, since we don’t have the budget to actually hire a programmer. I’ve tried using AI (forgive me), and while the code itself looks okay, it’s not working when I trigger the automation.

Product:
Wix Editor, Velo code in an automation

What are you trying to achieve:
My idea is that when a contact card is moved in the onboarding workflow, a unique 6-digit number is generated and either saved to the contact’s custom field, “membership number”, or at least to a collection in the Wix CMS.

What have you already tried:
I’ve looked through the velo help articles, tried Gemini, ChatGPT and Wix’s AI chatbot to write, run or debug the code (again, forgive me, but I don’t have any programmer friends). I feel like I’m missing something glaringly obvious but I just can’t figure out how it would work.

Additional information:
Example code
ChatGPT:

Wix automatically generates unique IDs in the _id field, sure you need a custom implementation of it?
It shouldn’t be too hard but probably unnecessary (?)

Well that would probably solve the problem. Thank you!
What would be an easy way to see this ID? It doesn’t show in the contact card and I don’t want to export the members every time.