_______________________________________________________________________________________________________________________
string wc;
string location;
string contacto;
string contacto_final;
int thelength;
location = format("%s",chg.affected_contact.location);
wc = format("wftpl=%d",wf_template.id);
if (wf_template.auto_assign == 1) {
send_wait(0,top_object(), "call_attr", "lrel_svc_grps_svc_wftpl", "sync_fetch","DYNAMIC", wc, -1, 0);
if (msg_error()) {
logf(ERROR, "Autoasignacion: '%s'", msg[0]);
}
thelength = msg[1];
object workflow;
workflow=msg[0];
int i;
i=0;
for (i; i<thelength; i++) {
send_wait(0, top_object(), "get_co_group");
send_wait(0, workflow, "dob_by_index", "DEFAULT", i, i);
send_wait(0, msg[0], "call_attr", "cnt", "get_val");
contacto=format("%s",substr(msg[0],0,32));
wc = format("id=U'%s'",substr(msg[0],0,32));
send_wait(0,top_object(), "call_attr", "cnt", "sync_fetch","DYNAMIC", wc, -1, 0);
send_wait(0, msg[0], "dob_by_index", "DEFAULT", 0, 0);
send_wait(0, msg[0], "call_attr", "location", "get_val");
if (location == format ("%s",msg[0])) { contacto_final = format("%s",contacto); }
}
object group_lead;
send_wait(0, top_object(), "get_co_group");
if (msg_error()) {
errmsg = format("AI SPELL :: get_co_group error: '%s'", msg[0]);
logf(ERROR, errmsg);
return;
}
group_lead = msg[0];
int err_stat;
err_stat = 1;
while (err_stat) {
send_wait(0, group_lead, "checkout", this);
if (!msg_error()) {
err_stat = 0;
} else {
sleep(1);
}
}
send_wait(1, this, "call_attr", "group", "set_val", (uuid)contacto_final, "SURE_SET");
send_wait(1, this, "call_attr", "assignee", "set_val", "NULL", "SURE_SET");
if (msg_error()) {
logf(ERROR, "AI SPELL :: call_attr.set_val error: %s", msg[0]);
return;
}
else {
if(is_null(group)){
send_wait(1, this, "call_attr", "group", "set_val", "31B1BC7F0E4C6A4B92C08AFB267232AD", "SURE_SET");
}
send_wait(0, group_lead, "checkin");
if (msg_error()) {
logf(ERROR, "AI SPELL :: group_leader checkin to %s error: %s", cnt_dob.sym, msg[0]);
send_wait(0, group_lead, "uncheck");
}
}
}
________________________________________________________________________________________________________________________
enjoy it!!!!!