building a custom Auto Number

building a custom Auto Number

I would like to create a deluge that will populate a field with a "work ticket number"

That number I would like to build off of the last ticket done per "driver."

So, what I would like to see is perhaps the last 4 digits of a driver's record ID followed by an auto number +1

1. Let's say John Doe is added in the system and his Record ID is = 3935501000003104005
2. We should see his first-ever work ticket number auto-populated as 4005-1000
3. His next ticket done would be 4005-1001 and next 4005-1002 and so on.

I think I'm almost there, but need to replace "theDay" line 3 with some script that will get me the last 4 of the driver ID.  I do not need the day in my Work Ticket Number.

I have created a deluge on Driver Field Ticket > Created > User input of Driver > AutoTicketNumber

lastOrder = Test_123[Driver.Name = input.Driver.Name] sort by Added_Time DESC range from 1 to 1;
//type-auto number-year
theDay = Today.getDay();
if(lastOrder.count() > 0)
{
getSuffixFirstDash = lastOrder.Work_Ticket.getSuffix("-");
getNumber = getSuffixFirstDash.getprefix("-");
newNumber = getNumber.toDecimal() + 1;
input.Work_Ticket = theDay + "-" + newNumber;
}
else
{
input.Work_Ticket = theDay + "-" + 1000;
}