I’m trying to make a script to make product planning easier in conjunction with the gantt chart.
I have four fields.
- startDate (date)
- endDate (formular)
- depended (link field to same table)
- lookUp (looks up the endDate via the depended link field)
In the first record I put I set a startDate and endDate gets automatically calculated based on various parameters.
in the second record link to to the first record and and the look up field looks up the above endDate, which my script then passes into the startDate and then it stops.
My problem is that I want to have a bunch of records stacked on top of each other. Set the dependency field (which job it should follow) and press a button and then it’ll pass the lookUp endates into every start date, but because the lookUp takes a little time to update, it stops after the the first date.
Is there away to make kind of make if loop over itself again and again until all dates with dependencies are filled?
const luPlanRecords = await prodView.selectRecordsAsync();
console.log(luPlanRecords.records)
for(let record of luPlanRecords.records){
let startDate = record.getCellValue(prodStartDate);
let endDate = record.getCellValue(prevFinishDate)
if(startDate !== endDate && endDate !== null ){
await prodTable.updateRecordAsync(record,
{'start (vs2)': new Date(endDate)});
}
};
I’ve been playing around with a while loop, but that didn’t help me much.
Does anyone have any idea how I can solve this problem?