I am modifying the close-task-and-all-subtasks example in order to set the state of the subtasks based on calculations.
The calculations is easy for the current entity using args.currentEntities as all the arguments of the current entity is received by the button script and available to be used in my calculations.
How do I get access to the args.currentEntities of the subtasks ?
The ...task["Subtasks"].map( (st) => {console.log(st)}) iterates the “Subtasks” and in the console log the Id and Name of every subtask is available.
How do I get all the arguments (args.currentEntities) of the specific entity using the Id available ?
My code is as follows:
const api = context.getService("fibery");
await Promise.all(args.currentEntities.map(async (e) => {
const task = await api.getEntityById(e.type, e.id, ["Subtasks"]);
console.log(task);
return Promise.all([
...task["Subtasks"].map( (st) => {
console.log(st);
})
])
}));
