Hello everyone, i have a set of tasks that once a lead moved from one stage to another those tasks should be created. The set of tasks already listed in a Table called "Tasks Reference", content of the table as below:
Linked with another table called "Tasks Stages Reference", content of table as below:
"Tasks Stages Reference" this table is have all possible stages that the lead can go through.
I also built a junction table that will have the tasks that will be created for any lead, called "To Do's", as below:
Here's the script:
let inputVariables = input.config()
let lead = inputVariables.leadName
let stage = inputVariables.stageName
let leadTrackingT = base.getTable('Lead Tracking');
let tasksT = base.getTable("To Do's");
let stagesTemplateT = base.getTable('Tasks Stages Reference');
let stageTasks = [];
if (stage) {
for (let task of stage.getCellValue('Tasks Reference')) {
stageTasks.push(
{
fields: {
'Task': task.name,
'Lead': [ {id: lead.id} ]
}
}
)
}
}
while (stageTasks.length > 0) {
await tasksT.createRecordsAsync(stageTasks.slice(0, 50));
stageTasks = stageTasks.slice(50);
}
Once i test this script an error keeps coming as below:
below are the inputs: