Thank you for your replies.
I'm not using classic workflow tasks, the tasks are put between a group start and group end, and can be completed in any order.
Here's what I have so far. The trigger is the following mod:
OBJECT cr_wf {
TRIGGERS {
POST_VALIDATE z_tsk_comp_jv() 12030
FILTER((EVENT("UPDATE")));
};
};
cr_wf::z_tsk_comp_jv(...)
{
string method, wc_1;
int nr_tasks, i, tsk_comp;
object tasks, task, tt, group_leader;
method = 'cr_wf::z_tsk_comp_jv';
wc_1 = format("cr='%s'", cr);
send_wait(0, top_object(), "call_attr", "cr_wf", "sync_fetch", "STATIC", wc_1, -1, 0);
tasks=msg[0];
nr_tasks=msg[1];
tsk_comp=0;
//go through all the ticket tasks
for(i=0;i<nr_tasks;i++){
send_wait(0, tasks, "dob_by_index", "DEFAULT", i, i);
task=msg[0];
//Check if there are ticket tasks in status COMP, REJ or APP, and save the number of tasks in that state
if(task.status=="APP" || task.status=="COMP" || task.status=="REJ"){
tsk_comp++;
}
}
//if the number of ticket tasks is equal to the number of completed tasks, then set the ticket status to resolved
if(tsk_comp == nr_tasks){
send_wait(0, top_object(), "get_co_group");
group_leader = msg[0];
send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, cr);
tt=msg[0];
send_wait(0, group_leader, "checkout", tt);
send_wait(0, tt, "call_attr", "status", "set_val", 'RE', "SURE_SET");
send_wait(0, group_leader, "checkin");
}
}