AnsweredAssumed Answered

Comparing and creating serial numbers with letters and numbers

Question asked by swillette on Aug 14, 2012
Latest reply on Aug 15, 2012 by philmodjunk

Title

Comparing and creating serial numbers with letters and numbers

Post

I need to create a script that:

Creates a new range of serial numbers after the script checks another table field of serial numbers to make sure that serial number hasn’t been used.

So my user types in how many serial numbers he/she wants in a Quantity field.

Puts in the starting serial number in a field.

The script checks all current serial numbers to make sure that it isn’t used, creates a new record in another table field with the new serial number, then adds a one to it and checks again…and so forth.

The serial numbers have to be created manually, and they each have to be unique.

Some serial numbers in the range may be used already.

The serial numbers also have to have an ARR00001 (3 letters and zeros in front of the last number (s) to equal 5 digits in all. (examples: ARR00022, ARR00112, etc.)

Here is my script:

Set Error Capture [ On ]

Set Variable [ $$Count ; Value:"" ]

Go to Layout [ “Firearms” (Firearms) ]

Show All Records

Go to Record/Request/Page

[ First ]

Loop

If [ FirearmsSerialCreation::SerialRangeNumber1 = Firearms::__SerialNumberID_pk ]

Go to Record/Request/Page

[ Next ]

Else

Go to Layout [ “Firearms Serial Creation” (FirearmsSerialCreation) ]

New Record/Request

Set Field [ FirearmsSerialCreation::__SerialNumberID_pk ; FirearmsSerialCreation::SerialRangeNumber1 ]

Set Field [ FirearmsSerialCreation::SerialRangeNumber1 ; SerialIncrement ( FirearmsSerialCreation::SerialRangeLetters ; "0000"&1 ) ]

Set Variable [ $$Count ; Value:$$Count + 1 ]

Go to Layout [ “Firearms” (Firearms) ]

Go to Record/Request/Page

[ Next ]

Exit Loop If [ $$Count = FirearmsSerialCreation::SerialRangeQuantity ]

End If

End Loop

Go to Layout [ “Firearms Serial Creation” (FirearmsSerialCreation) ]

In this script, I have a separate field for the 3 letters and a field for the numbers. I would like it to work with just one field for the serial number.

Outcomes