PLM 360 General Discussion

PLM 360 General Discussion

Reply
Contributor
MJ-Carol
Posts: 17
Registered: ‎08-15-2012
Message 1 of 18 (374 Views)
Accepted Solution

Year in Computed Field for autonumbering

374 Views, 17 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
piggeej
Posts: 281
Registered: ‎03-27-2012
Message 2 of 18 (363 Views)

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
PringaultJ
Posts: 1
Registered: ‎06-17-2011
Message 3 of 18 (333 Views)

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
piggeej
Posts: 281
Registered: ‎03-27-2012
Message 4 of 18 (328 Views)

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
MJ-Carol
Posts: 17
Registered: ‎08-15-2012
Message 5 of 18 (312 Views)

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
adminplm360
Posts: 50
Registered: ‎04-08-2013
Message 6 of 18 (234 Views)

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
mazerab
Posts: 207
Registered: ‎11-20-2012
Message 7 of 18 (216 Views)

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
adminplm360
Posts: 50
Registered: ‎04-08-2013
Message 8 of 18 (215 Views)

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
mazerab
Posts: 207
Registered: ‎11-20-2012
Message 9 of 18 (192 Views)

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
adminplm360
Posts: 50
Registered: ‎04-08-2013
Message 10 of 18 (190 Views)

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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.