Automatically create a Reference number

Hello community!

I need your experience and advices.

The app that I am creating is made to create reports for a transport company.

So basically i just need a reference number for each report that is created.

What do you guys think about the best way to do it?

—> Create a new data type called “reference_number”?

—> Use Reports unique ID and try to change the format?

Looking forward to hear about your thoughts.

Best…
Clem

If reference number works similar to a foreign key, then you can just get away with unique ID.

If you want to structure it differently, you can use slugs.

1 Like

Thank you @ntabs, ended up solving it throught creating a field in my reports dedicated to ref_numbers and used Calculate formula —> Generate random string. :slight_smile:

1 Like

Nice. Glad you figured it out.

One thing though… You could’ve just used the slug field instead of creating a new field.

@ntabs, thank you for your reply, this is an interesting idea you have there, can you please develop it? How can you automatically change the slug format for it to look like (Ex: 23-01, 23-02, etc…) with a +1 for each report created?

Cuz you are right, if this is possible to do, that’s a better and easier way to do it :slight_smile:

Well, if you already figured this out, you can just change the slug since the slug is pretty much the same as any other field. The only difference is that when you change a slug, you need to use the action “set a thing’s slug”

Saves you the time and data weight of creating another field.

Since slugs have a text field type by default, you would need to reference to the slug’s value, convert it to number, and add 1

EDIT: Another concern is what if you reach 99? Would you need to move to the next set of numbers like 23-99-01 or would you be fine with 23-100?

If it’s the former, you’d need to look for a way to limit it to 99 and move to the next set of numbers

You legend :sunglasses:

Thanks @ntabs i’ll have a look on that!

1 Like