• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk PLM 360

    Reply
    Active Member
    Posts: 11
    Registered: ‎08-15-2012
    Accepted Solution

    Year in Computed Field for autonumbering

    116 Views, 4 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

    Please use plain text.
    Product Support
    Posts: 152
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    New Member
    PringaultJ
    Posts: 1
    Registered: ‎06-17-2011

    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
    Please use plain text.
    Product Support
    Posts: 152
    Registered: ‎03-27-2012

    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.

    Please use plain text.
    Active Member
    Posts: 11
    Registered: ‎08-15-2012

    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

     

    Please use plain text.