The sequence element is useful for generating a formatted sequence number, optionally independent of the Primary Key (PK) of the form. For example, INV0001 for invoices.
Settings
- Affix Position - should the affix you specify be a prefix or suffix (like SKU0001 or 0123-SKU)
- Affix - the string to prefix or suffix the sequence number with. Can either be a fixed string (like SKU or INV, etc), or can use {table___element} Placeholders. For example, if you want to use a dropdown menu with the year to use as the affix, you might specify "{yourtable___year}-" to generate sequences like "2017-0001".
Note: that the plugin maintains separate sequences for each affix used. So if your year changes to 2018, the sequencing will start from the beginning.
- Method - choice of 3 methods:
- On Load - the sequence number will be generated as the form loads. This means the sequence can be seen when creating the form, but you will get gaps in the sequence if someone loads a form but never submits it, and you can't use element Placeholders in the affix (as element don't have values when you load a new form).
- On Submit - the sequence is generated during form submission, so no gaps, but it can't be seen when creating the form.
- Use PK - in this mode, the row's Primary Key is used as the sequence number, rather than maintaining a separate one for this element. Will ignore any "Start" value, and won't maintain a separate sequence for different affixes.
- Start - the value to start the sequence at, ignored by the "Use PK" method, defaults to 1.
- Padding - the 0 padded size of the sequence number, like "0001", defaults to 4.
Notes
The first time you select this element type, it will create a new metadata table, #__fabrik_sequences, which is used to track the sequence numbering by table name (the database table associated with the form), element ID and affix.
As it uses table name, rather than form/list ID, if you have copies of a list/form, the sequence same sequence will be used in all copies.
This plugin does NOT work for in repeated or joined
Groups. It is designed only to work for an element on the main form, in a non-repeated group.
Uses
1. Let us assume you have Client
White
Tiger ({tablename___client_name}) and you want to add first alphabet Affix to the Sequence Element. For eg.
WT-001.
Add following code to the Calc Element {tablename___client_affix}):
Code:
$words = preg_split('/\s+/', '{table_name___client_name_raw}');
$acronym = "";
foreach ($words as $w) {
$acronym .= $w[0];
}
return $acronym;
Then add / prepend {tablename___client_affix} this in 'Affix' field of Sequence Element.