You can also use status transition but for that you will need condition macro like this:
example for the change
string wc;
int active_count;
wc = format("parent = %s AND status != 'CL'", id);
send_wait(0, top_object(), "call_attr", "chg", "sync_fetch", "MLIST_STATIC", wc, -1,0);
active_count = msg[1];
logf(SIGNIFICANT,"%s",active_count);
if (active_count > 0) {
set_return_data(FALSE);
}else
{
set_return_data(TRUE);
}
for cr it should look similar to this:
string wc;
int active_count;
wc = format("parent = '%s' AND status != 'CL'", persistent_id);
send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "MLIST_STATIC", wc, -1,0);
active_count = msg[1];
logf(SIGNIFICANT,"%s",active_count);
if (active_count > 0) {
set_return_data(FALSE);
}else
{
set_return_data(TRUE);
}
as you see for cr in where clause you need to use persistent id and specify cr instead of chg for send_wait call
I have attached macro for change case. You can load it by using the following command:
pdm_load -i -m -f check_for_active_childs.macro