CA Service Management

  • 1.  Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Dec 13, 2017 11:31 PM

    Hi All,

    We are using SDM 17.0 and the classic workflow for Request tickets.
    I would like to set Group in Group field(assignee) in Request automatically
    when the status on Workflow Task is Completed. We click on status "Completed" within Workflow Task
    and select the option "Update Actions on True" and select Action Macro which is Request/Incident/Problem Workflow Task object type, but no Action Macro available to apply.
    We have never created Action Macro, I run command pdm_extract to export Action Macro from Spell_Macro table
    but I don't know how to create fragment code for macro, Could anyone assist me with create macro fragment please?

     

    Thanks and Regards,

    Komgrit



  • 2.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Dec 14, 2017 12:58 PM

    what will be you requirement?

    what define with group to be assigned?

    Do you want to pass the group assignee to the task to the group of the request?

    Let us  know maybe we already have one available for you we can share.

    concerning the syntax of the fragement.

    First of all please note that custom action macro are not supported by CA so you are on own there.

    That say nothing much complex there.

    you write your code like you will do with spel (except you don't have to define the objject as you are already on)

    the you need to escape any special character like "e: with \ and use \\0012 as return carrer for visibility as you have mostly see when extraction one.

    Below a example of code that will assign the group from the task to group of the request and the final file content ready for import with pdm_load so you can compare

    Using a tool like notepad++ will quickly help for all the replacement.

     

    object cr_dob;
    send_wait(0, this, "call_attr",  "cr", "get_dob");
    if (msg_error())
    {
    logf(ERROR, format("unable to retrieve cr associated to wf"));
    return;
    }
    cr_dob= msg[0];
    if(!is_null(cr_dob))
    {
    send_wait(0, top_object(), "get_co_group");
    if (msg_error()){
    logf(ERROR, "get_group_leader () failed: %s", msg[0]);
    return;
    }
    object gl;
    gl = msg[0];
    send_wait(0, gl, "checkout", chg_dob);
    if (msg_error())
    {
    logf(ERROR, "Error checking out dob, error: %s", msg[0]);
    return;
    }
    cr_dob.group=group;
    send_wait(0, gl, "checkin");
    }

    TABLE Spell_Macro
     del description fragment id last_mod_by last_mod_dt lock_object msg_html
     msg_tmpl_info ob_type persid sym tenant type usr_integer1 usr_integer2 usr_integer3
     usr_string2 usr_string3 usr_string4
     { "0" ,"Sets the CR group to the task group",
     "object "cr_dob;\\0012send_wait(0, this, \"call_attr\",  \"cr\", \"get_dob\");\\0012if (msg_error())\\0012{\\0012logf(ERROR, format(\"unable to retrieve cr associated to wf\"));\\0012return;\\0012}\\0012cr_dob= msg[0];\\0012if(!is_null(cr_dob))\\0012{\\0012send_wait(0, top_object(), \"get_co_group\");\\0012if (msg_error())\\0012{\\0012logf(ERROR, \"get_group_leader () failed: %s\", msg[0]);\\0012return;\\0012}\\0012object gl;\\0012gl = msg[0];\\0012send_wait(0, gl, \"checkout\", chg_dob);\\0012if (msg_error())\\0012{\\0012logf(ERROR, \"Error checking out dob, error: %s\", msg[0]);\\0012return;\\0012}\\0012cr_dob.group=group;\\0012send_wait(0, gl, \"checkin\");\\0012}",
     "" ,"" ,"" ,"1" ,"" ,"" ,"cr_wf" ,"" ,"Set CR group",
     "" ,"ACT" ,"" ,"" ,"" ,"" ,"" ,"" }

    Hope this help

    /J

    P.S.: if this is the logic that you would like to implement, just copy  the entire table spell_macro above to a text file and import using pdm_load -iv -f mytextfile



  • 3.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Dec 20, 2017 01:56 AM

    Dear Jerome Mayer,

     

       Thank you very much for your help, it's work but I edit something in line 18, I change from chg_dob to cr_dob.

    object cr_dob;
    send_wait(0, this, "call_attr",  "cr", "get_dob");
    if (msg_error())
    {
    logf(ERROR, format("unable to retrieve cr associated to wf"));
    return;
    }
    cr_dob= msg[0];
    if(!is_null(cr_dob))
    {
    send_wait(0, top_object(), "get_co_group");
    if (msg_error()){
    logf(ERROR, "get_group_leader () failed: %s", msg[0]);
    return;
    }
    object gl;
    gl = msg[0];
    send_wait(0, gl, "checkout", cr_dob);
    if (msg_error())
    {
    logf(ERROR, "Error checking out dob, error: %s", msg[0]);
    return;
    }
    cr_dob.group=group;
    send_wait(0, gl, "checkin");
    }



  • 4.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Dec 20, 2017 02:02 AM

    yes good catch

    a mistype when I was transforming the OOB script from chg to cr object

     

    Glad that this have help

    /J



  • 5.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Jan 17, 2018 09:29 AM

    Hi Jerome,

     

    How can I create an action macro to when the classic workflow task change the status to Approved, the parent ticket request is transfered for a specified group?



  • 6.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Jan 17, 2018 09:29 AM

    Hi guys,

     

    How can I create an action macro to when the classic workflow task change the status to Approved, the parent ticket request is transfered for a specified group?



  • 7.  Re: Action Macro in Classic Workflow to set Group in Request Tickets

    Posted Jan 17, 2018 10:01 PM

    My approach to this requirement would be as follows:

    ObjectEventAction
    cr_wfStatus goes to Approved, launching BehaviorBehavior runs Action macro 'zcrwfTransferGrp' against the cr_wf object, attaches event 'zcrTransferGrp' to the cr.
    Event 'zcrTransferGrp'Event fires in the context of the cr to which it is attachedEvent runs out-of-box action macro 'Transfer to Event Group' to transfer the ticket to a group.  The group is set in the 'Text' field of the event 'zcrTransferGrp'.

     

    The action macro 'zcrwfTransferGrp' will look something like this:

    TABLE Spell_Macro
        del description fragment last_mod_by last_mod_dt lock_object msg_html
        msg_tmpl_info ob_type sym tenant type usr_integer1 usr_integer2 usr_integer3
        usr_string2 usr_string3 usr_string4
        { "0" ,"Attach evt to transfer CR to group",
        "\\0012misc::site_att_cr_evt( \"zcrTransferGrp\", cr, 1, \"zcrx\" );",
        "" ,"" ,"1" ,"" ,"" ,"cr_wf" ,
        "zcrwfTransferGrp" ,"" ,"ACT" ,"" ,"" ,"" ,"" ,"" ,"" }

    The function 'misc::site_att_cr_evt' called by the macro follows.  Set 'ZDEBUG' to 0 once you have tested successfully, to avoid cluttering 'stdlog'.  Put this in site\mods\majic as 'zcrAttEvt.spl':

    #define ZDEBUG 99
    //
    // Attach an event identified by its symbol ('event_sym') to a CR identified by its persid ('cr_persid').
    // The event is attached with delay 'delay_sec'.
    // Pass the string 'SLA' as 'event_group_id' to attach the event as a Service Type event.
    // If the event is not to be treated as a Service Type event, pass a  string such as 'zxx' as 'event_group_id'.
    //
    // Set your local time zone in 'myTZ' below, although I'm not sure that the TZ argument is actually used.
    //
    void misc::site_att_cr_evt( string event_sym, string cr_persid, int delay_sec, string event_group_id )
    {
       string method;
       method = "misc::site_att_cr_evt";

       // This is Western Australia... set to your local TZ.
       string myTZ; myTZ = "GMT+0800 (2)";
       
       if ( ZDEBUG > 0 ) logf(SIGNIFICANT, "%s: Started ", method);
       //check symbol of event
       int evt_id;
       evt_id = (int)expand(format("&{'%s' = evt.sym->id}", event_sym));

       if ( is_null(evt_id) || (evt_id == 0) )
       {
          logf(ERROR, "%s: Symbol of event '%s' is not recognized.", method, event_sym);
          return;
       }

       if ( ZDEBUG > 0 ) logf(SIGNIFICANT, "%s: Event sym '%s' verified, attaching with delay %d...", method, event_sym, delay_sec);

       send_wait(0, top_object(), "call_attr", "evt", "new_attached_event", (object)NULL,
                 cr_persid, event_sym, (duration) delay_sec,
                 (date) NULL, event_group_id, 0, 0, myTZ);

       if (msg_error())
       {
          logf(ERROR, "%s: error returned by new_attached_event: %s", method, (string)msg[0]);
          return;
       }

       if ( ZDEBUG > 0 )
       {
          logf(SIGNIFICANT, "%s: Attach event called ", method);
          object attevt;
          attevt = msg[0];
          send_wait(0, attevt, "call_attr", "id", "get_val");
          int attevt_id;
          attevt_id = msg[0];
          logf(SIGNIFICANT, "%s: Finished. Attached event id = %d", method, attevt_id);
       }
    }

    The event 'zcrTransferGrp' is created against the Request / Incident / Problem object type and just needs to call the out-of-box macro 'Transfer to Event Group'.  Put the group label in the 'Text' field of the event:

    Event configuration tab

    Hope you find that useful.

    Regards,

    James