Creating a random serial number / reference number in inventory
I am creating a workshop inventory, it will include tools, but also hardware, like bolts & nuts, washers, drill bits or paint, brushes and various stocked material, metal, wood, etc...
For each entry I need a reference such as AB-yymmddxx where xx is a unique entry reference 01, 02, 03 etc up to 99 so each day I can enter 99 piece of equipment in tthe db
So far I have used the following trigger after update:
if not Reference then
let y := year(Date);
let m := month(Date);
let d := day(Date);
let c := cnt(select Articles where year(Date) = y and month(Date) = m);
Reference := y + format(m, "00") + format(d, "00") + format(c, "00")
else
void
end
It works except for the two reference letters AB- and the year displayed as yyyy
I have not found the string for two letters 'AB' or 'AD" followed bu a dash '-'
Could you help?
4 replies
-
Try this:
if not Reference then
let y := format(Date,"YY");
let m := format(Date,"MM");
let d := format(Date,"DD");
let c := cnt(select Articles where year(Date) = y and month(Date) = m);
Reference := "AB-"+y + m + d + format(c, "00")
endSteven
-
Steven, Thanks, I understand what you are saying it's logical, at the mement all my items are tagged AB-20012600 it's not incrementing AB-2001260x etc
Should I add a create trigger maybe something like:
'Articles' := max((select Articles).'Reference') + 1
Also what about else and void at the end?
Forgive me but I just got Ninox a couple of days ago and have not found in the manual a clear and detailed syntax reference guide. A petty really as it's powerful enough and I am dying to put my teeth into it.
-
Hi,
Here's a reference of scripting: https://ninoxdb.de/en/manual/calculations/reference-of-functions-and-language
you could also have look at (there's a free membership also): https://www.nioxus.com/ninox-manual-nioxus.htm
Try replacing this in he code:
let c := cnt(select Articles where format(Date,"YY") = y and format(Date,"MM") = m) + 1
and for the void, sometimes the scripteditor add this automaticaly...
Steven
-
An if you are using a cloud subscription, you could ask support@ninoxdb.de to add you to the Webinar EN 2020 team where you can find a lot of usefull examples. Also joining the weekly webinars on tuesdays is very usefull to learn all about ninox. Here's the link : https://zoom.us/webinar/register/WN_zoSk2qyNSz6vLRFF1zlakg
Steven
Content aside
- 5 yrs agoLast active
- 4Replies
- 1419Views