Good morning to you,
I'm trying to create dynamic ToDoLists.
At first, I thought I could solve my problem by using complete NoCode (see my post).
Finally, after some advice, I turned to @Giovanni_Briggs code and post.
I've never coded the day before yesterday, and I'm trying to use AI tools to understand what I'm doing.
I've managed to adapt the proposed code to my base and half of what I want to do works.
As it happens, my code copies the tasks from my original list very well,
It links the new tasks to the event we've validated internally,
But it doesn't create a link between parent and child tasks (I've been tearing my hair out for 24 hours trying to solve this problem).
To explain, each parent task (main task) is linked to several subtasks (child tasks).
example : The Hotel task
is therefore linked to several subtasks:
Hotel search
Validation of a hotel according to quotation and price/quality ratio
Hotel reservation
Hotel payment
Receipt of invoice
When I use my script, everything works fine except for the dependencies part.
Once again, I saw this subject mentioned in Giovanni_Briggs' post.
But my limited knowledge of the subject prevents me from achieving what I want!
Thank you in advance for your time, I don't know what to try to solve my problem!
Here my code :
const tableTachesV3 = base.getTable('Tâche (V3)');Thank you in advance for your time, I don't know what to try to solve my problem!
const tableTodoList = base.getTable('ToDo Lists');
// Fonction pour copier une tâche dans la Todo List
async function copierTache(NomDuCongres, RecordIDCongres, tache, tachesCopiees) {
const nomTache = tache.getCellValue('Name');
const categorie = tache.getCellValue('Catégories');
// Création de la tâche dans la Todo List
const tacheTodoList = await tableTodoList.createRecordAsync({
'Name': nomTache,
Catégories: categorie,
'Lien vers congrès': >{ id: RecordIDCongres, name: NomDuCongres }],
});
// Stockez la correspondance entre la tâche d'origine et la copie
tachesCopieesntache.id] = tacheTodoList;
return tacheTodoList;
}
// Fonction pour établir les dépendances entre les tâches de la Todo List
async function etablirDependances(tache, tachesCopiees) {
const dependancesTacheV3 = tache.getCellValue('Records (Nested)'); // Assurez-vous que cela correspond à votre base de données
if (dependancesTacheV3) {
// Créez un tableau pour stocker les dépendances ToDo Lists
const dependancesTodoList = p];
// Parcourez les dépendances Tâche (V3) et mappez-les aux enregistrements ToDo Lists correspondants
for (const dependance of dependancesTacheV3) {
const dependanceName = dependance.name; // Nom de la dépendance dans Tâche (V3)
// Trouvez la tâche ToDo Lists correspondante à partir du nom de la dépendance
const dependanceTodoList = tachesCopieesedependanceName];
if (dependanceTodoList) {
dependancesTodoList.push(dependanceTodoList);
}
}
// Ajoutez les dépendances ToDo Lists à la tâche ToDo List
if (dependancesTodoList.length > 0) {
await tableTodoList.updateRecordAsync(tache, {
'Records (Nested)': dependancesTodoList,
});
}
}
}
// Fonction pour copier toutes les tâches d'un congrès dans la Todo List
async function copierToutesTachesDansTodoLists(NomDuCongres, RecordIDCongres, taches) {
const tachesCopiees = {};
// Copiez toutes les tâches dans la Todo List
for (const tache of taches) {
await copierTache(NomDuCongres, RecordIDCongres, tache, tachesCopiees);
}
// Établissez ensuite les dépendances
for (const tache of taches) {
await etablirDependances(tache, tachesCopiees);
}
}
// Point d'entrée - Déclenché lorsqu'un congrès est validé
async function lorsqueCongresEstValide() {
const inputConfig = input.config();
const congresNom = inputConfigs"Nom du congrès"];
const congresRecordID = inputConfig<"Record ID congrès"];
const tachesV3 = await tableTachesV3.selectRecordsAsync();
// Utilisez le nom du congrès passé en paramètre pour copier les tâches dans la Todo List
await copierToutesTachesDansTodoLists(congresNom, congresRecordID, tachesV3.records);
}
// Point d'entrée - Déclenché lors de la validation d'un congrès
lorsqueCongresEstValide();