View all Blog posts

Tip Tuesday! Fusion Lifecycle Sequencers in Action (scripts)

By     JANUARY 24, 2017

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);

There’s more information in the Help guide on the Sequencer Object in the Scripting Reference section (also see Create a Named Sequencer in the Scripting Examples).

Bonus!  Jared Sund created a quick video showing how you can test your sequencer before you deploy it.  Have a look!