# IF Formula Help

• 0
• Question
• Updated 11 months ago
• (Edited)
Hello,

I'm super new to quickbase and it's array of functions and commands and I'm getting a lot of info from here and the tech support! So, I'm trying to make an auto generating Job Number based on 3 main things to make it look like this: 18034-20 ; so the "18" is the year the job was created, the "034" is the number, we don't ever get close to 1000 jobs a year, we're a small specialty construction business, and the "-20" is the ID for which department(which is a drop-down selector for either Fabrication or Construction).

So using the Formula below, when I select Fabrication it returns 18034-10 and when I select Construction it returns -2018034.

Formula:
If([Department ID]="Fabrication",
If([Record ID#]>=1 and [Record ID#]<10, Right(ToText(Year([Quote - Date of Bid])),2)&"00"&[Record ID#]& [Department ID],
[Record ID#]>=10 and [Record ID#]<100, Right(ToText(Year([Quote - Date of Bid])),2)&"0"&[Record ID#]& [Department ID],
Right(ToText(Year([Quote - Date of Bid])),2)&[Record ID#]), "-20")&

If([Department ID]="Construction",
If([Record ID#]>=1 and [Record ID#]<10, Right(ToText(Year([Quote - Date of Bid])),2)&"00"&[Record ID#]& [Department ID],
[Record ID#]>=10 and [Record ID#]<100, Right(ToText(Year([Quote - Date of Bid])),2)&"0"&[Record ID#]& [Department ID],
Right(ToText(Year([Quote - Date of Bid])),2)&[Record ID#]), "-10")

Any help would be greatly appreciated!

edit: oh and as for the reasoning why I have all the additional formatting for the Job Number for the "034" is so it's always 3 digits.
• 172 Points

Posted 11 months ago

• 0
• 72,438 Points
Can you live with the number not starting at 001 each year?  That will be a whole lot simpler if you can accept that.

If you can live with that, then the formula will be

(not tested, so please post back if there are any syntax errors)

var text Dept = Case([Department ID],
"Construction", "10",
"Fabrication", "20", "error");

var text YY = Right(ToText(Year([Quote - Date of Bid])),2);

var text Number = Right("00" & ToText([Record ID#]),3);

\$YY & \$Number & "-" & \$Dept

The formula above uses formula variables to break up the syntax into smaller bite size units.

• 172 Points
Scratch that, fixed it myself! :D Thank you so much for the help!
• 72,438 Points
OK, that you have it fixed, but you do not want it to be based on the current year, if that means the year of Today() as that will change the numbering for historical quotes when the Year of Today changes to 2019.
• 172 Points
I already got help with a QB engineer on the Quote number generation. However we have many cases where we quote something and get the job a year or two later. If I change [Quote - Bid Date] to [Today] it'll only change for the job number, right? I don't see how it'll change the quotes date as well.
• 72,438 Points
I’m not sure now what formula you are using and if you are using the bid date or the quote date.
• 1,406 Points
If you change the [Quote - Bid Date] to Today() are you wanting a quotes date to change to Today() as well?
If so you could use the date change as a trigger for a Quick Base Action then use the Action to change the date.