I’m trying to create a script that would copy a set tasks that I have identified as my “template” set for use in multi-project tracking. My script would create all the new tasks for a new projects based on the template. The template tasks have a linked field for predecessor’s to use in the Gantt block (my goal is project schedule tracking).
I figured out how to copy all the template tasks and prepend those task names with a mnemonic so they are unique. In doing that, I realized I can’t create the links in the predecessor field at the same time because the records are created serially and as such many of the links for a record don’t yet exist. I want to keep the same relative linking between records to allow for a new Gantt block to show the new project schedule with appropriate links. From there I can edit the projects dates and add/remove tasks specific to that project.
Here is the code to create the records.
for(let record of templateViewRecords.records) {
await tasks.createRecordAsync({
"Name": projectMnemonic + ' ' + record.getCellValue("Name"),
"Start Date": record.getCellValue("Start Date"),
"End Date": record.getCellValue("End Date"),
"Category": record.getCellValue("Category"),
"Phase": record.getCellValue("Phase"),
"Notes": record.getCellValue("Notes"),
});
};
I can’t quite figure out how to create the relative links. My thought was to cycle through the template records again and for each one find the new record with the appended mnemonic and then update the predecessor field with links to the new records, also with the prepended mnemonic.
Any help would be appreciated.
