How to automatically create a new order number in specific format after user submits the add new form?

We would like to have a new ERD number generated automatically in specific format after the user submits the form, after submitting the form user will be redirected to view page where he will be able to see all the details including the new ERD number..

ERD-20-0123 where 20 is the current year and the 0123 number that follows the sequence +1

I'm thinking to use the last ERD No as a starting point..

Any ideas how to achieve this? 

![](upload://nqgsEgHE8loyYtdrdpEp4bIqrBW.png) 

 

![](upload://fQ8XPTfVgHXyqbLQza6XEbi5PWS.png)

Thanks David, it works now.

Henryk, text formulas are a little broken in recognizing fields sometimes. So try removing the date field from your formula and re-adding it by selecting it from the dropdown that appears when you start typing the field's name. That should make it recognize the field correctly.

Hi, I get the same error with Invalid date no matter what format of date I'm trying to use/extract..? 

397069755451, just re-sent my reply to your email. Let me know if you didn't get it!

Hey Henryk,

This can be implemented fairly simply:

  1. Create a new Auto-Increment field if you don't already have one.
  2. Create a new Text Formula field and use the formula found here: https://gist.github.com/hmnd/14edf7b1ddbe98542211c8757ea9bfc2, replacing the Date/Time and Auto Increment field names with your own.

If you need your id numbers to be 4 digits long, I would suggest adding an equation field that adds 1000 to your Auto Increment field, since Knack does not currently have a built-in way to zero-pad numbers, unfortunately.

If you need further help with this or anything else dev or Knack related, feel free to reach out to me at david@hmnd.io! :)