+1 vote

I want to use an API (Gelato) that asks for a unique order ID. I could generate a random number, but if I get unlucky, two users might be given the same number.

Can I access a unique user/program run ID?

Or have a variable which is shared across all runs of the program that I could increment on each run?

by (170 points)

1 Answer

+2 votes
Best answer

You could create a table in Airtable with just one record where you store the last order ID you generated. In your program, you would then withdraw that number and increment by one to use it in that run, updating Airtable as well.

It is a clunky solution but it will work. In the future you should not need to use an external provider to share the value of a variable across different program runs but that functionality is not yet implemented.

Another option is to generate a random number that is really big (with 10 digits, for example): technically there could be two ids that are the same but the likelihood of that happening is really small.

by (3.6k points)
selected by
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users