Hi,
On your advices, I changed events group_name to "Z_SLA" in a PRE_VALIDATE trigger, and they are not cancelled.
To continue to display them in the service type screen, I change them to "SLA" just after the transfert in the POST_CI trigger and re-attach the SLA to the incident.
I have to do more testing to see if there's no another side effect, but for now, it seems to works pretty fine.
So, thanks to you two for the support !
Best regards,
Chris.
cr::zcr_sla(...)
{
logf(SIGNIFICANT, "%s: ref_num = %s", "cr::zcr_sla",(string)argv[15] );
logf(SIGNIFICANT, "%s: zconcerned_application = %s", "cr::zcr_sla",(string)argv[6] );
string cr_persid,cr_id,att_sla_persid;
int attach_events;
attach_events = 1;
cr_persid = argv[18];
cr_id = substr(cr_persid,3,strlen(cr_persid));
uuid who;
send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
who=msg[0];
if(argv[20] != argv[21] && !(is_null(argv[20]) || (string)argv[20] == "")){
cr::zupdate_atev(cr_persid,"group_name","SLA",who);
attach_events =0;
}
if ((argv[2] == argv[3]) && (argv[5] == argv[6]) && argv[20] == argv[21])
return;
string _category, _zenvironnementINC;
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "pcat", format("persistent_id ='%s'",(string)argv[9]),"sym");
if (msg_error()) {
logf(ERROR, "Error for getting category symbol %s : ", msg[0]);
return;
}
_category = msg[0];
if (_category != "Application/SVA")
return;
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "zdata_environnementINC", format("id =%d",(string)argv[12]),"sym");
if (msg_error()) {
logf(ERROR, "Error for getting zenvironnementINC symbol %s : ", msg[0]);
return;
}
_zenvironnementINC = msg[0];
if (_zenvironnementINC != "Production" && _zenvironnementINC != "Homologation")
return;
string _priority, _zconcerned_application;
_priority = (string)argv[3];
_zconcerned_application = (string)argv[6];
string new_sla;
string zapp_persid;
string zsla_p1,zsla_p2,zsla_p3,zsla_p4;
if(_priority == "1") {
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "zappl", format("id=U'%s'",_zconcerned_application),"zsla_p1");
if (msg_error()) {
logf(ERROR, "Error for getting zconcerned_application sla %s",msg[0]);
}
else {
new_sla = msg[0];
}
}
else {
if(_priority == "2") {
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "zappl", format("id =U'%s'",_zconcerned_application),"zsla_p2");
if (msg_error()) {
logf(ERROR, "Error for getting zconcerned_application sla %s",msg[0]);
}
else {
new_sla = msg[0];
}
}
else {
if(_priority == "3") {
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "zappl", format("id =U'%s'",_zconcerned_application),"zsla_p3");
if (msg_error()) {
logf(ERROR, "Error for getting zconcerned_application sla %s",msg[0]);
}
else {
new_sla = msg[0];
}
}
else {
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "zappl", format("id =U'%s'",_zconcerned_application),"zsla_p4");
if (msg_error()) {
logf(ERROR, "Error for getting zconcerned_application sla %s",msg[0]);
}
else {
new_sla = msg[0];
}
}
}
}
object newobject;
string zattached_sla;
logf(SIGNIFICANT, "cr_id %s - cr_persid %s", cr_id, cr_persid);
if(attach_events > 0)
send_wait(0, top_object(), "call_attr", "api", "insert_object", who, "attached_sla", NULL, 0, "map_sdsc", new_sla, "ticket_id", cr_id, "ticket_type", "cr", "_mapped_cr", cr_persid);
else {
send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "cr", format("id =%s",cr_id),"sla_violation");
if (!msg_error())
send_wait(0, top_object(), "call_attr", "api", "insert_object", who, "attached_sla", NULL, 0, "map_sdsc", new_sla, "ticket_id", cr_id, "ticket_type", "cr", "_mapped_cr", cr_persid,"sla_viol_status",msg[0]);
}
if (!msg_error()) {
newobject = msg[0];
zattached_sla = newobject.id;
logf(SIGNIFICANT, "new attached_sla id %s", zattached_sla);
if(attach_events >0)
cr::add_attached_events(new_sla,cr_persid,zattached_sla,who);
else
cr::zupdate_atev(cr_persid,"owning_ast",attached_sla,who);
}
}
cr::add_attached_events(string service_type, string cr_persid, string attached_sla, uuid who) {
logf(SIGNIFICANT, "cr::add_attached_event %s", service_type);
int count;
string _event;
object group_leader;
send_wait(0, top_object(), "get_co_group");
if (msg_error()) {
logf(SIGNIFICANT,"Error'%s'", msg[0]);
return;
}
else{
group_leader = msg[0];
}
send_wait(0, top_object(), "call_attr", "api", "get_list", "slatpl", who, format("service_type='%s'",service_type), -1);
if (msg_error()) {
logf(SIGNIFICANT,"Error %s",msg[0]);
}
else {
object obList;
count = msg[1];
obList = msg[0];
logf(SIGNIFICANT, "nb event %d",count);
send_wait(0, top_object(), "call_attr", "api", "get_list_values", who, obList,0,count,0,"event");
if (msg_error())
logf(SIGNIFICANT,"Error %s",msg[0]);
else {
int i;
count = 0;
string event_persid_list[30];
for (i=2;i<msg_length();i=i+3) {
event_persid_list[count]=msg[i];
logf(SIGNIFICANT,"msg[%d]: %s", i, msg[i]);
logf(SIGNIFICANT,"event_persid_list[%d]: %s", count, event_persid_list[count]);
count++;
}
for (i=0;i<count;i++) {
logf(SIGNIFICANT,"msg[%d]: %s", i, event_persid_list[i]);
_event = event_persid_list[i];
logf(SIGNIFICANT,"Event[%d]: '%s' on %d", i, _event,count);
object Objevt;
send_wait(0, top_object(), "call_attr", "evt", "dob_by_persid", 0, _event);
if (msg_error()) {
logf(SIGNIFICANT,"Error %s",msg[0]);
}
else
{
Objevt = msg[0];
send_wait(0, top_object(), "call_attr", "evt", "new_attached_event_obj", NULL, cr_persid,Objevt, Objevt.delay_time,(date) NULL, "SLA", 0, 0,"");
if (msg_error())
logf(SIGNIFICANT,"Error %s",msg[0]);
}
}
cr::zupdate_atev(cr_persid,"owning_ast",attached_sla,who);
}
}
}
cr::zupdate_atev(string inc_persid, string field, string value,uuid who) {
int i,count;
object obList;
send_wait(0, top_object(), "call_attr", "api", "get_list", "atev", who, format("obj_id='%s'",inc_persid), -1);
if (msg_error()) {
logf(SIGNIFICANT,"Error %s",msg