Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Year in Computed Field for autonumbering

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
MJ-Carol
1211 Views, 21 Replies

Year in Computed Field for autonumbering

Hi Support Officer,

 

I am currently setting up a new workspace and I need to make use of the computed field for auto numbering. I need the last 2 digit of the year to appear in between my auto numbering. With the script below, I managed to get MPCR000001 but I really would like the number to be MPCRYY0001 instead. The YY represent the current year and changes whenever a new year arrived.For year 2013, the autonumber will look like this MPCR130001.

 

('MPCR' + dbo.PAD_ZERO(6, convert(varchar,REQUEST_NUMBER__AUTO_INC)))

 

Is there a way to do this? Really appreciate your help and advice.

 

Many thanks.

Carol

Tags (1)
21 REPLIES 21
Message 21 of 22
dvirh
in reply to: MJ-Carol

Hi Carol

 

You can easily reset the sequence number back to 1 at the beginning of the year. The way the sequencer work is by giving you the next unused number for a given ‘Seed’ string value. If you use a new seed string in the new year, you will get a new sequence starting in 1 (or any other number that you want). In the example given, the seed is the word ‘mpcr’. You can change the seed to include the year number and that will automatically give you a new seed at the beginning of each year

 

Here is an example of how you could do that:

 

var today = new Date();

var seed = 'MPCR' + today.getFullYear().toString().slice(-2);

var mySeq = Sequencer.get(seed);

var itemNumber = seed + ('0000' + mySeq.nextValue()).slice(-4);

item.ITEM_NUMBER_FIELD = itemNumber;

Hagay Dvir
Engineering Manager
Fusion Manage
Autodesk, Inc.
Message 22 of 22
dvirh
in reply to: MJ-Carol

Carol,

 

With respect to the week number, this will need to be calculated. Unfortunately there is no function in JS to caclulate it directly, so you will need to create your own function. I found the following function on the web that calculates the week number based on the ISO standard. According to that standard, the weeks start on Monday and week 1 is the week that includes January 4:

 

var d = new Date();
d.setHours(0,0,0);
d.setDate(d.getDate()+4-(d.getDay()||7));
WOY = Math.ceil((((d-new Date(d.getFullYear(),0,1))/8.64e7)+1)/7);
Hagay Dvir
Engineering Manager
Fusion Manage
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report