We have about 50 files. Each file represents a component we want to track, therefor we spawn 50 new records. At the end of a WF transition, a WF script creates all the new records but we get a script timeout error. (script ran too long....exceeds 9 secs)
I've talked to support previously so this is not a new issue. If I remove the milestone creation code in my onCreate script, I can create approx. 80 records within the time limit. But I still need to create the milestones at some point.
Also, all 50 items are managed in another workspace, under a project management tab. Is there a way I can create the milestones for each of the 50 items outside of the onCreate behaviour?
if you can wait for sometime, you can consider the escalation script. i.e., in the first state after the item created, enable the escalation and make it run the script to create milestone. the script will be run one by one for each item, will have less chance to get the timeout error.
Are your "Files" or records specific to a single milestone/workflow stage or can they be grouped by Milestone/WF Stage?
If not, I would suggest looking for a way to better group your Files by Milestone or WF Stage.
A technique we use to circumvent the 9sec rule is using Chained Scripts.
To do this we start with templates to capture the Tasks (Files in your case) that relate to each Milestone.
This would require 3 workspaces; Project Milestone Templates, Project Milestones, Project Tasks.
The "Project Milestone Templates", uses a Grid Tab to store your Tasks (Files) fields as well as a reference to the Milestone each one relates to (a text field that relates to the Milestone). You may already be doing this...
Then on your WF transition, you create the Milestones (actual milestones) as well as the Project Milestones, you can also associate these with the Milestones to show progress.
Your Project Milestone has a simple workflow [planned, scheduled, complete] and on the planned to scheduled transition ( let's call it "START_MILESTONE") you have a script that adds the Tasks from the template (Grid) just for that milestone.
When you create the Milestones you can choose to "start" all of them or just the first one, which you do by calling item.project.children[i].performWorkflowTransitionByCustomID('START_MILESTONE', 'Some Comment'); which in turn triggers the workflow transition script to add the tasks to the Milestone.
This will effectively kick off several Chained scripts, each one being bound by the 9sec restriction, but together Chained scripts have 90sec to complete.
Here is an example of what the Project tab looks like:
Project Items 3-7 haven't been started yet so the "Tasks" have not been created below them.