CA Service Management

Expand all | Collapse all

Attach Service Type on Custom Field

  • 1.  Attach Service Type on Custom Field

    Posted Feb 10, 2017 07:25 AM

    Hi Team,

     

    Every location has a custom field zlocationtype (like 'Headquarter' etc.) associated with it.

     

    Is it possible to attach service type directly on cr object depending upon the custom location type of selected affected end user?

     

    If yes, how it can be achieved?

     

    Thanks & Regards,

    Balram



  • 2.  Re: Attach Service Type on Custom Field
    Best Answer

    Posted Feb 10, 2017 07:57 AM

    Hi,

    Can easily be done using a trigger and small spl but you can also look to attach an event to some activities The events can then attach any others SLA events you would like to.

     

    There is already an activity association on the cr object for the affected end user (customer).

    • Create a new activity notification for it (AEU update for example)
    • Search for the Affected end user activity association and change the type  to your newly created one (AEU update in my example)
    • Create a new  Attach Event macro  with the events you would like to attach there 
    • Create a new condition macro  (you will have to upload it as you can't create from the interface) with what you would like to check for. Something like below for example:
      if(customer.location.zlocationType. == "Headquarter"){
      set_return_data(TRUE);
      }else{
      set_return_data(FALSE);
    • Create a new event (Headquarter SLA) using the previously condition and action macro created. Adapt settings to meet your requirements
    • Add this new event (under the event tab) to the Activity notification you created at the beginning

     

    The above must work perfectly fine if you have only 1 or 2 sla to attach base on your zlocationtype. More dynamic will require more complex code in your condition macro or the use or trigger/spl.

     

    Just writing here out of my mind so not tested at all but hope this help to give you the principle.

     

    /J



  • 3.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 12:00 AM

    Hi Jerome Mayer,

     

    Thanks for providing this solution.

    Can you provide the trigger and spel code for the same?

     

    Regards,

    Balram Singh Deswal



  • 4.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 03:28 AM

    Hello Balram,

     

    Will the above example not meet your requirements?

    i will strongly advise you to do with the standard functionality if this will satisfy your requirements vs. customization that will by definition be not supported by CA.

    Spl code will also require to know what exact service types/events you want to attach, the business logic you want to apply, etc.

    Then will require your full functional requirements and some more info on your env.

     

    Regards

    /J



  • 5.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 07:13 AM

    Hi Jerome,

     

    How the macro will be uploaded? Kindly suggest.

     

    Regards,

    Balram



  • 6.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 10:17 AM

    You will need to use pdm_load to upload the macro.
    A good technic is to do an extract from a similar condition macro on the same object using a pdm_extract like below where you will replace with an id of your system

     

    pdm_extract -f  "Select * from Spell_Macro where id=123456" > yourpath\mymacro.txt

     

    you then modify as you need  the description, fragment, sym and others of your choice. When ready you upload back using the command below


    pdm_load -i -v -f yourpath\mymacro.xt (note the -i that force to do an insert vs trying to matching an existing for update)

     

     

    below is the fragment to replace based on the previous example I provided you:

     

    \\0012if(customer.location.zlocationType.sym == "Headquarter"){\\0012set_return_data(TRUE);\\0012}else{\\0012set_return_data(FALSE);\\0012


    Hope this help
    /J



  • 7.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 07:23 AM

    Apart from the procedure the upload the macro, if the zlocationType is SREL to the table storing the information of Location type, do I need to use "Headquarter" in condition or its id in database to check while creating the macro?



  • 8.  Re: Attach Service Type on Custom Field

    Posted Feb 13, 2017 10:05 AM

    if you have an SREL you will then need to supply the foreign key so mostly the id (or the persid in some case)

    You can also continue to specify the sym by extending the . notation like customer.location.zlocationtype.sym == "Headquarter" but I will not recommend as this i more resource consuming

    /J.



  • 9.  Re: Attach Service Type on Custom Field

    Posted Feb 14, 2017 11:26 PM

    Hi Jerome Mayer,

     

    I need your further support in this. I haven't worked much on macros, events earlier? Do I need to attach every event separately? Isn't possible to attach the service type as a whole? Here is what I have configured so far:

    Uploaded a custom macro "Head Quarter Location Type" with the content as follows:

     

    Created the following events and attached the above macro in the condition for each of them:

     

    After this, I created a service type Head_Quarter and added all the above events in that as follows:

    Now when I am creating the incident with affected end user having the location type as Head Quarter, it is not attaching the service type. You have also mentioned about creation of activity notification and attaching with affected end user association but I am not sure how to configure that. Can you provide some screenshots of the configurations that I need to do further?

     

    Kindly suggest.

     

    Thanks & Regards,

    Balram



  • 10.  Re: Attach Service Type on Custom Field

    Posted Feb 15, 2017 02:52 AM

    You may want to review your action macro here as you syntax don't seems to be correctly missing bracket "{" as shown in my example.

    Did you check any errors in your log when this condition is evaluated?

     

    You must not attach the events to your service  type but directly to the corresponding activity notification under the events tab. Service type is just a collection of events so result is the same.

    i.e.  if you want this to be attach at creation of the ticket , you will attach the events to the Initial activity notification as explained in my initial response

     

    May you want as you just show above to atatch those events based on the lifecycle of the ticket vs. the modificaiton of the AEU you can just use the existing activity notification . there will be no need to create new one. The only restriction there is that changing the AEU afterward will not attach/remove additional events.

     

    /J



  • 11.  Re: Attach Service Type on Custom Field

    Posted Feb 15, 2017 04:44 AM

    Thanks Jerome Mayer,

     

    It is working now after correcting the syntax. 

     

    Regards,

    Balram



  • 12.  Re: Attach Service Type on Custom Field

    Posted Feb 15, 2017 05:59 AM

    Glad to have been able to help.

    Please mark as correct answer if your problem is fix

    Thanks

    /J



  • 13.  Re: Attach Service Type on Custom Field

    Posted Feb 14, 2017 11:53 PM

    Apart from the configuration that I mentioned in previous comment, I have created a new Activity notification AEU Update and added the events that I configured in the events tab as follows:

     

    After this, I created an new activity association AEU Update with activity type as AEU Update and attribute as customer as follows:

     

    Still after creating the incident is not attaching the events/service type when the location type of the customer is "Headquarter". 

     

    Kindly suggest.

     

    Regards,

    Balram



  • 14.  Re: Attach Service Type on Custom Field

    Posted Feb 15, 2017 01:25 AM

    Adding further, I created attach event macro for all the events and added those macros in the respective events Action Information. Screenshot for one of the events is as follows:

    Attach Event Macro:

    Event Action Information Tab:

     

    Same thing I followed for all the events, yet it is not attaching the events to the incident.

     

    Kindly suggest.

     

    Regards,

    Balram



  • 15.  Re: Attach Service Type on Custom Field

    Posted Feb 16, 2017 05:29 AM

    Hi Jerome Mayer,

     

    Now I have implemented the complete use case by creating events and macros for all location types. But here I am attaching all the events (associated with all location types) on the events tab of the Initial activity notification. Based upon the condition, the action of the matching events are performed and rest are ignored. Is there any way that I can restrict the events that are attached on the incident based on the location type of the affected end user only as soon as the Incident is created?

     

    Kindly suggest.

     

    Thanks & Regards,

    Balram



  • 16.  Re: Attach Service Type on Custom Field

    Posted Feb 16, 2017 08:04 AM

    Hi again,

     

    This was one of my point at the beginning of this conversation.

    This setup is not really sustainable if If you need to manage this for multiple location.

     

    1/ Another way is to write more spl in your action macro where you will add the logic for each location into the code itself.

    Downside here is that this is hard coded so if you have to change or add new location/service type often this is not either nice to manage.

     

    2/ The more smart way will be to create a new object that will contain the service type/location relation and have your spell code retrieve it dynamically to attach to the ticket.

    That will of course require more knowledge and effort to setup but can be easily be managed afterwards trough the interface.

     

     

    3/ A complete different way can be to investigate if you can't virtually reorganize those users per organization vs. location.

    Organization have a service type field available out of the box and in this case the  service type will be automatically attached base of  the organization of the end user.

    This is exactly what you try to accomplish but using your location.

     

    As you can see here, this is always multiple approach to one single problem and this require strong analysis of the business requirements prior to come to the technical aspect.

     

    Hope this help

    /J



  • 17.  Re: Attach Service Type on Custom Field

    Posted Feb 17, 2017 12:17 AM

    Hi Jerome Mayer,

     

    Thanks for the alternative solutions. Organization approach seems to be helpful but in my case, but the attachment of service type/events is dependent on request area as well (apart from location type). I set that up in the condition of the macro as well and was working.

     

    One alternative that I am thinking of is to modify the priorities (Location-Type1, Location-Type2 etc) as per the requirement and set them on the form level using javascript depending on the values of customer and category.

     

    Is it possible for you to provide a spell code that will attach a service type 'Service Type' to an incident if the location type is 'Location' and category area is 'Area'? It will be very helpful.

     

    Thanks & Regards,

    Balram



  • 18.  Re: Attach Service Type on Custom Field

    Posted Feb 17, 2017 02:54 AM

    Hi Balram,

     

    I think then that my option 2 to create a new table and associated is mostly the best long term solution

     

    Please have a look to the post here from Gutis on example to attach event in spel

     

    /J



  • 19.  Re: Attach Service Type on Custom Field

    Posted Feb 22, 2017 11:27 PM

    Hi cdtj, Hi daniel-bighelini,

     

    Is it possible for you to provide a spell code with corresponding majic file that will attach a service type 'Service Type' to an incident if the location type of customer (customer.location.zlocation_type) is 400001 and category area is 'pcat:400002' as soon as the incident is created? 

     

    Kindly suggest.

     

    Thanks & Regards,

    Balram



  • 20.  Re: Attach Service Type on Custom Field

    Posted Feb 23, 2017 04:12 AM

    Hi Balram,

    in our environment we have implemented custom SLA managment and switched off OOTB SLA, so I'm not sure that can provide solution that can be work with OOTB SLA process (I can say that I'm not familiar with default SLA process).

    Attaching a single event can do the trick but I'm not sure what will happen to it when you: switch status or category.

    Regards,

    cdtj



  • 21.  Re: Attach Service Type on Custom Field

    Posted Feb 23, 2017 06:17 AM

    Hi cdtj,

     

    Thanks for your response.

     

    In case I need to attach 3 events 'E1', 'E2' and 'E3' instead of 'Service Type' in the above example, can you provide the spel code for this case?

     

    Regards,

    Balram



  • 22.  Re: Attach Service Type on Custom Field

    Posted Feb 23, 2017 07:24 AM

    Balram.Deswal

    Example of spel function to attach event in objects:

     

    string z_anexa_evento(...)
    {
        ////////////////////////////////////////////////////////////////////////////////
        // Metodo:            z_anexa_evento
        // Criado em:        11/06/2013
        // Autor:            Daniel Becker Bighelini
        // Modificado em:    21/11/2016
        // Modificado por:    Daniel Becker Bighelini
        ////////////////////////////////////////////////////////////////////////////////
        // Descricao:
        //
        //        Anexa um evento a um objeto.
        //
        // Parametros:
        //        argv[0]:    Atributo persistent_id do objeto que o evento sera anexado.
        //        argv[1]:    Nome simbolico do evento que sera anexado.
        //        argv[2]:    Atributo persistent_id do evento que sera anexado. Se for informado, o argumento sym argv[1] eh ignorado.
        //        argv[3]:    Tempo de espera em segundos antes de disparar o evento.
        //        argv[4]:    Data que o evento deve ser disparado.
        //        argv[5]:    [OPCIONAL] Define o nivel de depuracao da funcao (0=Desligado, 1=Log resumido, 2=Log detalhado). Se omitido, valor sera 0.
        //
        // Exemplo:
        //        z_anexa_evento('chg:99999', 'nome do evento', '', 600, 2013-06-11 15.00.00, 1)
        ////////////////////////////////////////////////////////////////////////////////

     

        // Variaveis globais do metodo
        int zi_depurar, zi_i;
        string zs_metodo, zs_resultado, zs_clausula, zs_msg;
        string zs_persistent_id, zs_event_name, zs_event_persid;
        duration zdu_delay_time;
        date zdt_date;
        
        // Atribuindo variaveis
        zs_metodo            = 'z_anexa_evento - ';
        //zi_depurar            = 1; // Alterar valor zi_depurar parar 1 para debug mode
        zs_persistent_id    = (string) argv[0];
        zs_event_name        = (string) argv[1];
        zs_event_persid        = (string) argv[2];
        zdu_delay_time        = (duration) argv[3];
        zdt_date            = (date) argv[4];
        if (argc>5) {zi_depurar    = (int) argv[5];}    
        
     
        // Entrada para debug mode
        if ( zi_depurar>=1 ) {
            logf(SIGNIFICANT, "%s Quant. de argumentos : %d", zs_metodo, argc);
            for (zi_i=0; zi_i<argc; zi_i+=1) {
                logf(SIGNIFICANT, "%s ARG #%s : %s", zs_metodo, zi_i, argv[zi_i]);
            }
        } else {
            logf(SIGNIFICANT, "%s '%s'", zs_metodo, zs_persistent_id);
        }

     

        ///////////////////////////////////////////////////////////////////////////////////////
        // Inicio do codigo

     

        // Variaveis de objeto
        object zo_atev_dob, zo_atev_list, zo_group_leader;
        int zi_atev_count;

     

        if (zi_depurar > 0) logf(SIGNIFICANT, "%s Obtendo GL...", zs_metodo);
        send_wait(0, top_object(), "get_co_group");
        zo_group_leader = msg[0];

     

        ////////////////////////////////////////////////////////////////////////////////
        // Removendo eventos existentes no objeto
        ////////////////////////////////////////////////////////////////////////////////

     

        // Identifica o persid do evento que sera removido
        if (is_empty(zs_event_persid)) {
            if (zi_depurar > 0) logf(SIGNIFICANT, "%s Identificando o persid do evento '%s'...", zs_metodo, zs_event_name);
            zs_event_persid = expand(format("&{%s = evt.sym->persistent_id}", zs_event_name));
            if (zi_depurar > 0) logf(SIGNIFICANT, "%s Persid do evento '%s': %s", zs_metodo, zs_event_name, zs_event_persid);
        }

     

        // Definindo clausula para procurar eventos no objeto desejado
        zs_clausula = format("event_tmpl = '%s' AND obj_id = '%s'", zs_event_persid, zs_persistent_id);
        send_wait(0, top_object(), "call_attr", "atev", "sync_fetch", "STATIC", zs_clausula, -1, 0);
        zo_atev_list = msg[0];
        zi_atev_count = msg[1];
        if (zi_depurar > 0) logf(SIGNIFICANT, "%s Quantidade de eventos localizados em '%s': %s", zs_metodo, zs_persistent_id, zi_atev_count);

     

        if (zi_atev_count > 0) {
            if (zi_depurar > 0) logf(SIGNIFICANT, "%s Cancelando %d eventos existentes no objeto '%s'...", zs_metodo, zi_atev_count, zs_persistent_id);
            for (zi_i=0;zi_i<zi_atev_count;zi_i++) {
                send_wait(0, zo_atev_list, "dob_by_index", "DEFAULT", zi_i, zi_i);
                zo_atev_dob = msg[0];
                send_wait(0, zo_group_leader, "checkout", zo_atev_dob);
                send_wait(0, zo_atev_dob, "cancel_me");
                send_wait(0, zo_group_leader, "checkin");
                if (msg_error()) {
                    logf(ERROR, "%s ERRO cancelando evento para o objeto '%s': %s", zs_metodo, zs_persistent_id, msg[0]);
                } else {
                    if (zi_depurar > 0) logf(SIGNIFICANT, "%s Evento '%s' cancelado com sucesso no objeto '%s'.", zs_metodo, zs_event_name, zs_persistent_id);
                }
            }
        }

     

        ////////////////////////////////////////////////////////////////////////////////
        // Anexando o evento ao objeto
        ////////////////////////////////////////////////////////////////////////////////
        if (zi_depurar > 0) logf(SIGNIFICANT, "%s Anexando evento '%s' (%s) ao objeto '%s'...", zs_metodo, zs_event_name, zs_event_persid, zs_persistent_id);
        if (zi_depurar > 0) logf(SIGNIFICANT, "%s Data de inicio: '%s' / Atraso: '%d' segundos", zs_metodo, zdt_date, zdu_delay_time);
        send_wait(0, top_object(), "call_attr", "evt", "new_attached_event", zo_group_leader, zs_persistent_id, zs_event_name, (duration) zdu_delay_time, zdt_date, "SLA", 0, 0, "");
        if (msg_error()) {
            zs_msg = format("%s ERRO ao anexar o evento '%s' no objeto '%s': %s", zs_metodo, zs_event_name, zs_persistent_id, msg[0]);
            logf(ERROR, "%s", zs_msg);
            return zs_msg;
        } else {
            if (zi_depurar > 0) logf(SIGNIFICANT, "%s Evento '%s' anexado com sucesso no objeto '%s': %s", zs_metodo, zs_event_name, zs_persistent_id, msg[0]);
        }

     

        if (zi_depurar > 0) logf(SIGNIFICANT, "%s Fazendo checkin...", zs_metodo);
        send_wait(0, zo_group_leader, "checkin");
        if (msg_error()) {
            zs_msg = format("%s ERRO ao fazer checkin no objeto '%s': %s", zs_metodo, zs_persistent_id, msg[0]);
            logf(ERROR, "%s", zs_msg);
            send_wait(0, zo_group_leader, "uncheck");
            return zs_msg;
        } else {
            if (zi_depurar > 0) logf(SIGNIFICANT, "%s Checkin realizado com sucesso no objeto '%s': %s", zs_metodo, zs_persistent_id, msg[0]);
            return "OK";
        }

     

        return;
        // Fim do codigo
        ///////////////////////////////////    
    }



  • 23.  Re: Attach Service Type on Custom Field

    Posted Feb 24, 2017 06:06 AM

    Hi Daniel,

     

    Thanks for this reference code. I will try to implement it as per my use case.

     

    Regards,

    Balram