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);
Scott,
Clever 🙂 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.
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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.