PLM 360 General Discussion

PLM 360 General Discussion

Reply
Contributor
19 Posts
9 Kudos
Registered: ‎08-15-2012
Post 1 of 22
Accepted Solution

Year in Computed Field for autonumbering

413 Views, 21 Replies
01-28-2013 10:32 PM

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

Carol,

 

Given the limited nature of SQL scripting ( SQL scripting is for all intents and purposes limited for math calculations with in the computed field), this would not be the best way of doing it.

I would suggest using an “on creation script” using JAVASCRIPT (which is much more flexible).

Product Support
282 Posts
48 Kudos
Registered: ‎03-27-2012
Post 2 of 22

Re: Year in Computed Field for autonumbering

01-29-2013 06:56 AM in reply to: MJ-Carol

Carol,

 

Given the limited nature of SQL scripting ( SQL scripting is for all intents and purposes limited for math calculations with in the computed field), this would not be the best way of doing it.

I would suggest using an “on creation script” using JAVASCRIPT (which is much more flexible).



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

New Member
1 Posts
1 Kudo
Registered: ‎06-17-2011
Post 3 of 22

Re: Year in Computed Field for autonumbering

02-20-2013 08:10 AM in reply to: MJ-Carol

Carol, Joe, 

 

What you can do on the Field is to put that :

 

('MPCR' + dbo.PAD_ZERO(6, convert(varchar,ID__AUTO_INC)) + CAST(CONVERT (varchar, GETDATE(),101) as CHAR(10)))

 

And for sure you will be abel to play with the convert substring ... function available on SQL

 

Regards & hope this help

 

 



Jeremy PRINGAULT
EMEA Business Consultant
Autodesk
Product Support
282 Posts
48 Kudos
Registered: ‎03-27-2012
Post 4 of 22

Re: Year in Computed Field for autonumbering

02-20-2013 08:21 AM in reply to: PringaultJ

Jeremy,

 

Good call, didn't think of it that way.



Joe Piggee
Support Specialist
Product Support
Autodesk, Inc.

Contributor
19 Posts
9 Kudos
Registered: ‎08-15-2012
Post 5 of 22

Re: Year in Computed Field for autonumbering

02-24-2013 06:26 PM in reply to: PringaultJ

Hi Jeremy,

 

Thank you for the solution, really appreciate it.

 

 

Best regards,

Carol Mak

 

Active Contributor
50 Posts
17 Kudos
Registered: ‎04-08-2013
Post 6 of 22

Re: Year in Computed Field for autonumbering

06-12-2013 08:02 AM in reply to: PringaultJ

Hi I would like to have the same thing.

 

I copied this: ('MPCR' + dbo.PAD_ZERO(6, convert(varchar,ID__AUTO_INC)) + CAST(CONVERT (varchar, GETDATE(),101) as CHAR(10))) on the computed field formula and it said that "Modifications to the computed field formula could not be saved. Check your formula syntax and try again." The data type is Auto Number

 

Can you help me and see what is wrong?

 

Thanks

 

Product Support
207 Posts
13 Kudos
Registered: ‎11-20-2012
Post 7 of 22

Re: Year in Computed Field for autonumbering

06-13-2013 03:10 PM in reply to: adminplm360

Hi Elias,

 

The value

('MPCR' + dbo.PAD_ZERO(6, convert(varchar,ID__AUTO_INC)) + CAST(CONVERT (varchar, GETDATE(),101) as CHAR(10)))

when entered and saved in my auto number computed field works without error for me.

 

Are you using a different default date format under general display settings? My current default is MM/dd/yyyy.

 

Regards,



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Active Contributor
50 Posts
17 Kudos
Registered: ‎04-08-2013
Post 8 of 22

Re: Year in Computed Field for autonumbering

06-13-2013 03:29 PM in reply to: mazerab
Hi
I have the same date format that you have.
Maybe is the part where it says exclude weekends from duration.
Product Support
207 Posts
13 Kudos
Registered: ‎11-20-2012
Post 9 of 22

Re: Year in Computed Field for autonumbering

06-14-2013 11:05 AM in reply to: MJ-Carol

Hi Elias,

Could you please try on a laptop instead of an iPad?

Regards,



Bastien Mazeran
Support Specialist
Product Support
Autodesk, Inc.
Active Contributor
50 Posts
17 Kudos
Registered: ‎04-08-2013
Post 10 of 22

Re: Year in Computed Field for autonumbering

06-14-2013 11:11 AM in reply to: mazerab

I did it in a laptop and it didn't work. I reproduced it in an iPad because I didn't have a laptop at that moment and I wanted to show you the print screen.

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!