I recommend to don't change status directly from macro but attach an event instead.
You need to have:
- chg event with attached action macro, call it CHG2APP for example;
- action macro that will change chg's status, some of them are presented out-of-the-box (name starts with Set CHG status);
First recomendation - check this doc: SPEL EVENT methods
To reduce routine you can create SPL file with followed function and call it when you need to attach an event:
string evt::z_new_evt(string evtkey, string obj_id, ...) {
string group_name;
duration timeout;
int i, delayed_start;
object gl, new_atev;
delayed_start = 0;
timeout = 15;
for (i=0;i<argc;i++) {
logf(SIGNIFICANT, "argv[%d]: %s", i, argv[i]);
}
if (sindex(evtkey, 'evt:') == 0) {
send_wait(0, top_object(), "call_attr", "evt", "val_by_key", "persistent_id", evtkey, 1, "sym");
evtkey = msg[1];
}
if (argc > 2) {
timeout = argv[2];
}
if (argc > 3) {
if (!is_empty(argv[3])) {
group_name = argv[3];
} else {
group_name = (string)NULL;
}
}
if (argc > 4) {
delayed_start = (int)argv[4];
}
send_wait(0, top_object(), "get_co_group");
if (msg_error()) {
for (i=0;i<msg_length();i++) {
logf(ERROR, "msg[%d]: %s", i, msg[i]);
}
return;
}
gl = msg[0];
send_wait(0, top_object(), "call_attr", "evt", "new_attached_event", gl, obj_id, (string)evtkey, (duration)timeout, now(), group_name, 0, delayed_start, "");
if (msg_error()) {
for (i=0;i<msg_length();i++) {
logf(ERROR, "msg[%d]: %s", i, msg[i]);
}
} else {
new_atev = msg[0];
send_wait(0, gl, "checkin");
if (msg_error()) {
logf(ERROR, "evt [%s] is not attached to [%s] with [%d] delay", evtkey, obj_id, timeout);
} else {
logf(SIGNIFICANT, "evt [%s] is attached to [%s] with [%d] delay", evtkey, obj_id, timeout);
return new_atev.persistent_id;
}
}
}
Next step:
- create action macro with followed code and execute it when you need to attach an event:
evt::z_new_evt('CHG2APP', chg.persistent_id);
this will attach event with name CHG2APP to your change orded with 15 sec delay.
Regards,
cdtj