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

    Autodesk PLM 360

    Reply
    Distinguished Contributor
    Posts: 146
    Registered: ‎10-04-2012

    Script Time Limit Exception

    95 Views, 4 Replies
    10-11-2012 04:00 PM

    Hi,

     

    I have developed a script to update the derived fields on some records I have imported (there is currently a bug where derived fields do not resolve during import - they only reolve when the item is edited). The problem is that I have over 5000 import records to modify (dmsID 50575 to 55716).

     

    The script below works (I use the workspace 'create' behaviour to call it). However when I try to run it for more then 200 or so records I get a 'ScriptTimeLimitException' error (see attached). Please advise.

     

    The scirpt is:

     

    //This script resolves derived fields. Required because serived fields do not resolve during import.

    record = 50575;

    do{
        var newItem = loadItem(record);
        if (newItem.CONTRACT_NUMBER4 != null){
            var linked_item = newItem.CONTRACT_NUMBER4;
            if (linked_item.CUSTOMER != null){
                newItem.CUSTOMER4 = linked_item.CUSTOMER;
            }
            if (linked_item.DETAILS != null){
                newItem.DESCRIPTION2 = linked_item.DETAILS;
            }
        }
        record++;
    }while(record <55717);

    Please use plain text.
    Employee
    broepke
    Posts: 103
    Registered: ‎01-24-2004

    Re: Script Time Limit Exception

    10-12-2012 06:45 AM in reply to: dkeeley

    Scott,

     

    Clever :smileyhappy:  That's a system limitation so we don't have "run away" scripts.  Think of cases where stuff is just so intensive that it actually affects the performance of your site, etc...  It's set to 500 ms.

     

    So - What you can do is break it down in chuncks.  Try processing 1/2 of them first.  Then edit the script and do the other 1/2.  That doesn't fly do 1/3 or whatever.

     

    (or chunks of 1000? I have no clue how many it can do... It will take some experimenting.



    Brian Roepke
    Director of Product Lifecycle Management
    Autodesk, Inc.

    Please use plain text.
    Distinguished Contributor
    Posts: 146
    Registered: ‎10-04-2012

    Re: Script Time Limit Exception

    10-12-2012 08:39 AM in reply to: broepke

    Hi Scott,

     

    I can only seem to get it to run for about 200 records at a time. Is there nay way to make the code more efficient as you see it? (i'm not a software person BTW) ;-)

     

    Thanks,

     

    David.

    Please use plain text.
    Distinguished Contributor
    Posts: 146
    Registered: ‎10-04-2012

    Re: Script Time Limit Exception

    10-12-2012 08:41 AM in reply to: dkeeley

    Sorry. Brian - not Scott.

    Please use plain text.
    Employee
    jared.sund
    Posts: 42
    Registered: ‎11-04-2011

    Re: Script Time Limit Exception

    10-12-2012 09:20 AM in reply to: dkeeley

    I don't see any obvious performance issues with your script, however you may be able to gain some performance using a multi-pick list and not the loadItem function.  This approach might take a couple of temp workspaces to get through the process, but could increase your chunk size. 

    Jared Sund
    Product Manager, Product Lifecycle Management
    Autodesk, Inc.
    Please use plain text.