PLM 360 General Discussion

PLM 360 General Discussion

Reply
Mentor
dkeeley
Posts: 224
Registered: ‎10-04-2012
Message 1 of 5 (177 Views)

Script Time Limit Exception

177 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);

Board Manager
broepke
Posts: 180
Registered: ‎01-24-2004
Message 2 of 5 (156 Views)

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 PLM & PDM
Autodesk, Inc.

Mentor
dkeeley
Posts: 224
Registered: ‎10-04-2012
Message 3 of 5 (150 Views)

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.

Mentor
dkeeley
Posts: 224
Registered: ‎10-04-2012
Message 4 of 5 (149 Views)

Re: Script Time Limit Exception

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

Sorry. Brian - not Scott.

Employee
jared.sund
Posts: 75
Registered: ‎11-04-2011
Message 5 of 5 (140 Views)

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
Sr. Product Line Manager, Product Lifecycle Management
Autodesk, Inc.
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.