Hi,
I can't attach script as file, so copy followed code and save it as z_status_change.frg.
You need to define correct where_clause (search query), new status code and status change comment on line 27, 57, 58.
Run command could be found within script file.
#define MSG_ERROR for(msg_i=0;msg_i<msg_length();msg_i++) { logf(ERROR, "msg[%d]: %s", msg_i, msg[msg_i]); }
#define MSG_SIGN for(msg_i=0;msg_i<msg_length();msg_i++) { logf(SIGNIFICANT, "msg[%d]: %s", msg_i, msg[msg_i]); }
#define MSG_BOTH if (msg_error()) { MSG_ERROR return; } else { MSG_SIGN }
stInit(...) {
set_ilimit(2147483648);
string wc;
int msg_i, zcount, i;
object cr, zfound;
wc = "id IN (5904179,5907121,5907172,5922428,5924266,5926653,5928594,5928599,5928827,5929126,5929343,5929363,5929420,5929633,5930136) AND active = 1 AND resolve_date is NULL";
send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "STATIC", wc, -1, 0);
zcount = msg[1];
printf("Found: %d\n", zcount);
if (zcount > 0) {
zfound = msg[0];
for (i=0;i<zcount;i++) {
send_wait(0, zfound, "dob_by_index", "DEFAULT", i, i);
if (msg_error()) {
printf("[%d] > Unablte to dob_by_index\n", i);
MSG_ERROR
} else {
cr = msg[0];
st(cr);
}
}
}
}
int st(object cr_obj) {
uuid who;
int msg_i;
object gl;
string comment, new_status;
new_status = "CNCL";
comment = "Rejected by Sith Lord";
send_wait(0, top_object(), "get_co_group");
gl = msg[0];
send_wait(0, top_object(), "call_attr", "cnt", "current_user_id");
who = msg[0];
printf("\tprocessing: %s...", cr_obj.ref_num);
send_wait(0, cr_obj, "change_status", gl,
who,
comment,
new_status,
NULL
);
send_wait(0, gl, "checkin");
if (msg_error()) {
send_wait(0, gl, "uncheck");
printf("fail\n");
return 1;
} else {
printf("ok\n");
return 0;
}
}
PS: test it well and use it at your own risk.
Regards,
Timur Alimov