Tip Tuesday! Fusion Lifecycle Sequencers in Action (scripts)
I initially talked about Sequencers when they were first introduced back in 2014 (New Sequencer Functionality). Today’s tip is an example of how to set up a customer numbering sequence that is based on the current year. This could come in handy for workspaces where having some intelligence in the number could be meaningful – perhaps in your Non Conformance or CAPA workspaces. People can see at a glance when the record was created if reviewing a list of items.
This was discussed not long ago in a Forum post, “Can I reset Sequencer start number via script”. Here’s a code snippet on how you could achieve this sort of numbering system:
//get the current year
var currentYear = new Date().getFullYear();
//change the year from four digits to two (2017:17)
currentYear = currentYear.toString().slice(-2);
//create or get a seqencer with the name NumberCounterTest17
var seq = new Sequencer("NumberCounterTest" + currentYear);
//set a field with YY-XXXX format.
item.ITEM_NUMBER = currentYear + '-' + ('0000' + seq.nextValue().toString()).slice(-4);
Bonus! Jared Sund created a quick video showing how you can test your sequencer before you deploy it. Have a look!