Skip to content

Generating a Reference Number

I remember way back when I first started using Podio one of the things I struggled with right at the start was generating something like a Project reference number. Now in Tape there are a few ways to achieve a unique reference number, depending on what you actually want to achieve.

Tape provides a built-in unique number field which gives your record a unique number within an app. You can also set the field to include a prefix or suffix to further customize the reference number.

View Screenshot

Thats the simplest way to generate a reference number, however that may not always be sufficient depending on your use case. As there are a few restrictions:

  • The number can’t be padded with zeros (e.g. 0001, 0002, etc.)
  • The prefix will not be carried over if the field is call/used in a different context.

Tape allocates a Record ID to each record, now this one is different to the Unique ID field as it is unique across the the whole of Tape every single record ever created. It also means that the numbers are now quite large 167113606 as an example. The other thing about this number is that there is not a field specificaly for this ID and infact untill recently you could only get it via an automation. However you can now access it in a record calculation field.

View Screenshot

parseInt(@record_id,10)

If neither of the above options work for you, you can always build your own reference number using a combination of fields and a calculation field.

I generaly use a combination based on date, Unique ID and some custom text. For example if I was creating a reference number for a project I might endup with something like this: View Screenshot

To achive this we do need two fields plus a calculation field:

  1. A date field (e.g. @created_at) - this is oftern worth having anyway and can be hidden.
  2. The Unique ID field (e.g. @unique_id) - again this can be hidden and is always worth having for use in automations.
  3. A calculation field to combine them (e.g. @reference_number) View Screenshot

Your calculation field would then look something like this:

`PRJ${date_fns.format( @Created on , 'yy')}${String( @Unique ID ).padStart(3, '0')}`

now that is doing quite a lot in one line so lets write it a different way and break it down:

const text = 'PRJ';
const year = date_fns.format(@Created on, 'yy');
const paddedUnique = String(@Unique ID).padStart(3, '0');
`${text}${year}${paddedUnique}`
  1. We need our prefix text:
    const text = 'PRJ';
  2. We need our year:
    const year = date_fns.format(@Created on, 'yy');
  3. We need our padded unique ID:
    const paddedUnique = String(@Unique ID).padStart(3, '0');
  4. We need to combine them all together:
    `${text}${year}${paddedUnique}`