Hi
I am creating an extended project planning tool. So i create an graph for the project in which the workload per week in presented.
For this I use data from a couple of tables (team, standaard uren (standard hours), Init en activiteiten (activities))
In order to create the graphical load per week I need to create subfases per main fase (hoofdfase)
What i am trying to do is retrieve the fase + number of weeks in order to write these in the table activiteiten and also teammember from teamleden. I managed to get to work through test2 … But now stuck.
Anybody willing to help? or maybe if you need more info, please let me know.
//let
let fases = [{
fase: "Voorbereiding",
startDate: startdatumV,
endDate: endDateV,
weeken: duurV,
id: records[0]
},
{
fase: "Campagne",
startDate: startDateC,
endDate: endDateC,
weeken: duurC,
id: records[1]
},
{
fase: "Nazorg",
startDate: startDateN,
endDate: endDateN,
weeken: duurN,
id: records[2]
}];
// await
fases.forEach(async (f) => {
for (let j = 0; j < f.weeken; j++){
console.log(j);
console.log(duurV);
console.log(duurC);
console.log(duurN);
console.log('test1');
let subfases = standaard_uren_tabel.selectRecordsAsync();
let teamlid = team.selectRecordsAsync();
console.log('test2');
let subfase = undefined;
subfase = subfases.records.filter(rec => {
return rec.getCellValue("Fase").name.localeCompare(f.fase) && parseInt(rec.getCellValue("Fase nummer")) === (j + 1);
});
let functie = teamlid.records.filter(rec => {
return rec.id.localeCompare(parentRecord.id);
});
console.log(‘test3’);
console.log(subfase[0].name);
console.log(functie[0].name);
let startDate = null;
let endDate = null;
if(j === 0){
startDate = f.startDate;
endDate = addWeeks(removeOneDay(f.startDate), (j+1));
} else if (j === f.weeken-1) {
startDate = addWeeks(f.startDate, j);
endDate = f.endDate;
}else {
startDate = addWeeks(f.startDate, j);
endDate = addWeeks(removeOneDay(f.startDate), (j+1));
}
console.log(subfase);
await activiteit.createRecordAsync({
"Hoofdfase": [{ id: f.id }],
"subfase": [{ id: subfase[0].id }],
"Start datum": startDate,
"Eind datum": endDate,
"Projectleider": [{ id: parentRecord.id }],
"Uren per week": parseInt(subfase[0].getCellValueAsString(functie[0].getCellValue("Functie").name))
});
}
})