FAQ: TFORMer Designer
Code Snippet: How Can I Create a Timestamp for a Unique Package ID?
Code Snippet: How Can I Create a Timestamp for a Unique Package ID?
Using timestamps is a workaround if you cannot use persistant serial fields. The following expression creates a 12-digit alphanumeric timestamp for a unique package ID (incremented with each print job).
CStr(Chr(65 + Year(Now()) % 26)) + CStr(Chr(65 + CLng(Format(Now(), "MM")) - 1)) + CStr(Chr(47 + CLng (IIF (Day(Now()) >10, 7, 0)) + Day(Now()))) + CStr(Chr(65 + Hour(Now()))) + Format(Now(), "mmss") + Format(PrintedItems, "0000")
- Converts year, month, hour to A-Z to save space.
- Converts day to A-Z, 0..7
- Includes the actual label copy as a 4 digit counter
Put this expressions into a calculated field like clPackageID (data type Text). If you use individual label copies calculate it per Record Copy.
8 Digit Version
With 8 digits, we can remove the year and the seconds and limit the serial part to 3 digits.
CStr(Chr(65 + CLng(Format(Now(), "MM")) - 1)) + CStr(Chr(47 + CLng (IIF (Day(Now()) >10, 7, 0)) + Day(Now()))) + CStr(Chr(65 + Hour(Now()))) + Format(Now(), "mm") + Format(PrintedItems, "000")
This auto-package id consists of a 5-digit timestamp (month/day/hour/minute) followed by a 3-digit sequence number. That means the number of items/pallets in one job is limited to 999 and the minimum time between print jobs must be 1 minute. The package id can repeat itself every year.