CA Service Management

 View Only
  • 1.  Issue with attached SLA

    Posted Jun 12, 2017 04:51 AM

    Hello,

     

    I wrote a spel to attach SLA to incident based on priority and a custom application field, which is below.

     

    It works great, but we have an issue when transferring to another group. The attached events are cancelled, and the attached sla is completely deleted, including in the database.

     

    And I do not have any clue about which code can cause this ...

     

    Does anyone have any idea what might happen?

     

     

    ////////////////////////////////////////////////////////////////////////
    // Method:      cr::zcr_sla()
    //
    // Description: sets the service level of the call request based
    //   on the concerned application and the priority.
    //
    //     
    // Input
    //     priority                        = argv[3];
    //     zconcerned_application      = argv[6];
    //  category                         = argv[9];
    //  zenvironnementINC               = argv[12];
    //  ref_num                              = argv[15];
    //  persistent_id                    = argv[18];
    //
    // Return
    //   None
    ////////////////////////////////////////////////////////////////////////
    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] );

    // If no prority or application change, return
         if ((argv[2] == argv[3]) && (argv[5] == argv[6]))
         return;

         string _category, _zenvironnementINC;
         
    // If category different of "Application/SVA", return
         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;
         

    // If environment different of "Production" and "Homologation", 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];
                        }
                   }
              }
         }     

         uuid who; 
         object newobject; 
         string zattached_sla;
         send_wait(0,top_object(), "call_attr", "cnt", "current_user_id"); 
         who=msg[0];
         string cr_persid,cr_id;
         cr_persid = argv[18];
         cr_id = substr(cr_persid,3,strlen(cr_persid));
         logf(SIGNIFICANT, "cr_id %s - cr_persid %s", cr_id, cr_persid); //log new object id 
         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); 
         if (!msg_error()) { 
              newobject = msg[0]; 
              zattached_sla = newobject.id;
              logf(SIGNIFICANT, "new attached_sla id %s", zattached_sla); //log new object id 
              cr::add_attached_events(new_sla,cr_persid,zattached_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); //log new object id

         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]; 
         }
    // Get event list linked to the service type
         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 each event, attach it to the incident
                   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]); 
                        }
                        
                   }

                   // Get attached events list
                   send_wait(0, top_object(), "call_attr", "api", "get_list", "atev", who, format("obj_id='%s'",cr_persid), -1);  
                   if (msg_error()) {  
                        logf(SIGNIFICANT,"Error %s",msg[0]);  
                   }  
                   else { 
                        count = msg[1]; 
                        obList = msg[0]; 
                        string atev_persid_list[30];
                        logf(SIGNIFICANT, "nb event to update %d",count); 
                        send_wait(0, top_object(), "call_attr", "api", "get_list_values", who, obList,0,count,0,"persistent_id");  
                        if (msg_error())  
                             logf(SIGNIFICANT,"Error %s",msg[0]);  
                        else { 
                             count = 0;
                             for (i=0;i<msg_length();i=i+3) {
                                  atev_persid_list[count]=msg[i];
                                  logf(SIGNIFICANT,"atev_persid_list[%d]: %s", i, atev_persid_list[i]);
                                  count++;
                             }
                             for (i=0;i<count;i++) {
                                  send_wait(0, top_object(), "call_attr", "api", "update_object", who, atev_persid_list[i], NULL, NULL, 0, "owning_ast", attached_sla);   
                                  if (msg_error()) 
                                       printf("create failed %s",msg[0]);   
                                  else
                                       logf(SIGNIFICANT,"atev %s updtated", i, atev_persid_list[i]);
                             }
                        }
                   }
              }
         }
    }


  • 2.  Re: Issue with attached SLA

    Posted Jun 13, 2017 08:24 AM

    Hi.

    I assume that the standard functionality which handles SLA's does remove your stuff.

    POST_VALIDATE cr::attached_sla_processing

     

    Try using a different so called group name when attaching sla events

     

    Instead of

     

    send_wait(0, top_object(), "call_attr", "evt", "new_attached_event_obj", NULL, cr_persid,Objevt, Objevt.delay_time,(date) NULL, "SLA", 0, 0,"");

     

    try something like

     

    send_wait(0, top_object(), "call_attr", "evt", "new_attached_event_obj", NULL, cr_persid,Objevt, Objevt.delay_time,(date) NULL, "Z_SLA", 0, 0,"");

     

    Let us know, if this helps.

    Kind regards

    .............Michael



  • 3.  Re: Issue with attached SLA

    Posted Jun 13, 2017 09:01 AM

    Hi,

     

    Thanks for your answer, unfortunately, that doesn't work, the attached events are not visible.

    The standard object schema defines sla_events like this :

    sla_events           QREL <- atev {obj_id = ? AND group_name = 'SLA'}

     

    So, the group_name "SLA" is mandatory.



  • 4.  Re: Issue with attached SLA

    Posted Jun 14, 2017 03:17 AM

    Hmm. You are right. But this is different question.

     

    The value 'SLA' isn't mandatory, at least from a data record / attached event / atev perspective.

     

    Your original question was related to the problem that your self written spell code creates attached events, which gets deleted / canceled whenever you change the group of the ticket.

     

    My assumption was, that this is happening due to some standard SDM code, which normaly handles creating and deleeting attached events, where I know from, that this code is looking for attached events with a group name of 'SLA'.

     

    Therefore my suggestion to use a different atev group name like 'Z_SLA', because 'SLA ' is already in use by the standard records and logic.

    Did you check if your attached events gets still deleted when using 'Z_SLA' and changing the group of the ticket?

    I'm quite sure you are aware that you can fetch the db data in various ways (pdm_extract, bop_odump,etc.) to see if the events are still there and running.

     

    That means, I'm primarely interested in, if another atev group name helps for your original problem.

    If yes , we can take a look at the question how to display the new self attached events in the standard SLA list as well.

     

    Kind regards.

    .............Michael



  • 5.  Re: Issue with attached SLA

    Posted Jun 14, 2017 04:52 AM
      |   view attached

    The reason your original events disappeared must be because there is a Service Type on the group to which the ticket was transferred.  And what controls that behaviour is, as Michael says, the event group name.  When you use something other than 'SLA' the events are no longer treated as SLA events, so they are not cancelled when the ticket is closed or when the priority is changed, and they won't disappear when the ticket is transferred.  You can still see the attached events via 'View / Event History'.  I use this technique regularly - although not so regularly now, since Activity Notification Events came along in r12.

     

    Regards,

    James



  • 6.  Re: Issue with attached SLA

    Posted Jun 15, 2017 04:35 AM

    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.

     

    ////////////////////////////////////////////////////////////////////////
    // Method:      cr::zcr_sla()
    //
    // Description: sets the service level of the call request based
    //   on the concerned application and the priority.
    //
    //     
    // Input
    //     priority                        = argv[3];
    //     zconcerned_application      = argv[6];
    //  category                         = argv[9];
    //  zenvironnementINC               = argv[12];
    //  ref_num                              = argv[15];
    //  persistent_id                    = argv[18];
    //  group                              = argv[21];
    //
    // Return
    //   None
    ////////////////////////////////////////////////////////////////////////
    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 group changed, then update attached sla group_name to "SLA"
         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 no prority or application change, return
         if ((argv[2] == argv[3]) && (argv[5] == argv[6]) && argv[20] == argv[21])
         return;

         string _category, _zenvironnementINC;
         
         
    // If category different of "Application/SVA", return
         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;
         
    // If environment different of "Production" and "Homologation", 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); //log new object id 
    // if group changed, insert new attached sla with incident sla violation value
         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); //log new object id 
         // if group changed, don't attach events, just update event with
              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); //log new object id

         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]; 
         }

    // Get event list linked to the service type
         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 each event, attach it to the incident
                   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]); 
                        }
                        
                   }
              // Update owning attached SLA
                   cr::zupdate_atev(cr_persid,"owning_ast",attached_sla,who);
              }
         }
    }

    cr::zupdate_atev(string inc_persid, string field, string value,uuid who) {
    // Get event list linked to incident
         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[0]);  
         }  
         else { 
              count = msg[1]; 
              obList = msg[0]; 
              string atev_persid_list[30];
              logf(SIGNIFICANT, "nb event to update %d",count); 
              send_wait(0, top_object(), "call_attr", "api", "get_list_values", who, obList,0,count,0,"persistent_id");  
              if (msg_error())  
                   logf(SIGNIFICANT,"Error %s",msg[0]);  
              else { 
                   count = 0;
              //     Update every event
                   for (i=0;i<msg_length();i=i+3) {
                        atev_persid_list[count]=msg[i];
                        logf(SIGNIFICANT,"atev_persid_list[%d]: %s", i, atev_persid_list[i]);
                        logf(SIGNIFICANT,"atev_persid_list[%d]: %s", i+1, atev_persid_list[i+1]);
                        logf(SIGNIFICANT,"atev_persid_list[%d]: %s", i+2, atev_persid_list[i+2]);
                        
                        count++;
                   }
                   for (i=0;i<count;i++) {
                        send_wait(0, top_object(), "call_attr", "api", "update_object", who, atev_persid_list[i], NULL, NULL, 0, field, value);   
                        if (msg_error()) 
                             printf("update failed %s",msg[0]);   
                        else
                             logf(SIGNIFICANT,"atev %s updtated", i, atev_persid_list[i]);
                   }
              }
         }
    }

    ////////////////////////////////////////////////////////////////////////
    // Method:      cr::zget_attached_sla()
    //
    // Description: sets events group_name to "Z_SLA" when ticket is transfered.
    //
    //     
    // Input
    //  group                              = argv[3];
    //
    // Return
    //   None
    ////////////////////////////////////////////////////////////////////////
    cr::zget_attached_sla(...) {
         if (argv[2] == argv[3])
              return;
         
         uuid who; 
         send_wait(0,top_object(), "call_attr", "cnt", "current_user_id"); 
         who=msg[0];
         
         cr::zupdate_atev(persistent_id,"group_name","Z_SLA",who);
    }


  • 7.  Re: Issue with attached SLA

    Posted Jun 19, 2017 09:22 AM

    You're welcome.

    even though you might have achieved what you were looking for, I wouldn't go that way, changing Z_SLA afterwards  back to SLA just to make them visible in the list ! What happens , if the ticket gets reassigned to another group again. And what happens if the ticket does not get reassigned?

     

    Instead I would change the "xx_stype_tab.htmpl" file not to iterate through the "args.sla_events" attribute, but using a pdm_list with whereclause instead...

    or ...

    directly change the definition of cr.sla_events  to

    sla_events           QREL <- atev {obj_id = ? AND ( group_name = 'SLA' or group_name ='Z_SLA'}

     

    Best regards

    ...........Michael