CA Service Management

  • 1.  Automatically resolve tickets after task validation?

    Posted Jan 03, 2019 12:07 PM

    Hello,

     

    I'm trying to create a spel that validates if all the tasks associated with a ticket are completed or approved, and if so, sets the state of the ticket as Resolved. I have been trying some things but the ticket doesn't update, even though the tasks are recognized as completed.

    Has anyone ever done something similar, and is able to help me?

     

    Thank you!



  • 2.  Re: Automatically resolve tickets after task validation?

    Posted Jan 03, 2019 10:06 PM

    Perhaps you can post some details regarding what you have tried so far.



  • 3.  Re: Automatically resolve tickets after task validation?

    Posted Jan 04, 2019 02:29 AM

    If you are using classic workflow tasks associated with a request area, I would suggest the following:

     

    If the individual tasks can complete in any order:

    1. Put a 'group start' task before the first of your individual tasks, and a 'group end' task after the final task;

    2. Make sure the 'approved' workflow task status has 'Task Completed' set to Yes (default out-of-the-box);

    3. Add a 'behavior' to the Group End task in the request area, on status 'Completed', to update the ticket status.

     

    If the individual tasks must complete sequentially:

    Add a final 'tasks complete' task, which has a 'behavior' on status Pending to complete the task itself, and a behavior on status Completed to update the ticket status.

     

    As Lindsay suggests, please get back to us with more details.  The more details you can supply, the more help we can be.



  • 4.  Re: Automatically resolve tickets after task validation?

    Posted Jan 04, 2019 05:16 AM

    Thank you for your replies.

     

    I'm not using classic workflow tasks, the tasks are put between a group start and group end, and can be completed in any order.

    Here's what I have so far. The trigger is the following mod:

    OBJECT cr_wf {
        TRIGGERS {
            POST_VALIDATE z_tsk_comp_jv() 12030
                FILTER((EVENT("UPDATE")));
        };
    };

    And the spel is the following spl:

    cr_wf::z_tsk_comp_jv(...)

    {

                    string method, wc_1;

                    int nr_tasks, i, tsk_comp;

                    object tasks, task, tt, group_leader;

                   

                    method = 'cr_wf::z_tsk_comp_jv';

                   

                    wc_1 = format("cr='%s'", cr);

                    send_wait(0, top_object(), "call_attr", "cr_wf", "sync_fetch", "STATIC", wc_1, -1, 0);

                    tasks=msg[0];                  

                    nr_tasks=msg[1];

                    tsk_comp=0;                    

    //go through all the ticket tasks

                    for(i=0;i<nr_tasks;i++){                               

                                   send_wait(0, tasks, "dob_by_index", "DEFAULT", i, i);

                                   task=msg[0];

    //Check if there are ticket tasks in status COMP, REJ or APP, and save the number of tasks in that state

                                   if(task.status=="APP" || task.status=="COMP" || task.status=="REJ"){

                                                   tsk_comp++;

                                   }

                    }

    //if the number of ticket tasks is equal to the number of completed tasks, then set the ticket status to resolved

                    if(tsk_comp == nr_tasks){

                                   send_wait(0, top_object(), "get_co_group");

                                   group_leader = msg[0];

                                   send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, cr);

                                   tt=msg[0];         

                                   send_wait(0, group_leader, "checkout", tt);

                                   send_wait(0, tt, "call_attr", "status", "set_val", 'RE', "SURE_SET");

                                   send_wait(0, group_leader, "checkin");

                    }

    }



  • 5.  Re: Automatically resolve tickets after task validation?

    Posted Jan 06, 2019 09:00 PM

    The Group End task will complete itself when all tasks in the group are completed (or have a status, such as Approved or Rejected, that marks the task as Completed).  So, if your Group Start and Group End tasks and at least one of the tasks in between are raised from the request area, you don't need to use a trigger - you can just put a 'behavior' onto the Group End task for status Completed which calls a macro to do the CR status update - without the need to check for uncompleted tasks.

    Having said that - does your spel above fail?  You might find it useful to add some 'logf' calls - as Aleksandar does - which might give you some more information.

     

    Hope that helps!

    Regards,

    James



  • 6.  Re: Automatically resolve tickets after task validation?

    Posted Jan 04, 2019 08:46 AM

    I used this function and it worked for me

     

     

    cr_wf::z_check_all_wf_are_closed(...)
    {
     string cr_id;
     cr_id=argv[0];
     send_wait( 0, top_object(), "get_co_group");
        if ( msg_error() ) {       
         logf( ERROR, "cannot get a group leader: %s",  msg[0] );
         return;
        } 
     object group_leader;
      group_leader = msg[0];
      send_wait( 0, top_object(), "call_attr", "cr", "dob_by_persid", 0, cr_id, NULL, group_leader);
       if (msg_error()) {
           logf(ERROR, " cannot get object :%s",  msg[0]);
           return; 
       }
       object z_cr;
        z_cr = msg[0];
     string where_clause;
     where_clause = format("cr =\'%s\'", z_cr.persistent_id);
     send_wait(0, top_object(), "call_attr", "cr_wf", "sync_fetch", "RLIST_STATIC", where_clause, -1, 0);
     object wf_list, request_obj ;
     int request_no, i;
     wf_list = msg[0]; request_no=msg[1];
     int flag;
     flag =0;
     for (i =0;i<request_no;i++)
     {
      send_wait( 0, wf_list , "dob_by_index", "DEFAULT", i, i );
      if ( msg_error() ) {
       logf( SIGNIFICANT, "cannot retrieve wf %s from the list: %s",  i, msg[0] );
       return ;
      }
      request_obj = msg[0];
      if (request_obj.status == 'COMP' && (request_obj.task != "GRPSTART" || request_obj.task != "GRPEND" ))
       flag = flag + 1;
      else if (request_obj.task == "GRPSTART" || request_obj.task == "GRPEND" )
       flag = flag + 1;
     }
     if (flag == request_no)
     {
      
       send_wait( 0, group_leader, "checkout", z_cr);
      if ( msg_error() ) {
       logf( SIGNIFICANT, "Cannot checkout the Request: %s",  msg[0]);
       return "false";
      }
      
        z_cr.status ="CL";
      
      send_wait(0, group_leader, "checkin");
      if ( msg_error() ) {
       logf( SIGNIFICANT, " Checkin unsuccesful: %s",  msg[0]);
       
      }
     }
     return;
    }


  • 7.  Re: Automatically resolve tickets after task validation?

    Posted Jan 09, 2019 04:12 AM

    Thank you for your replies.

    Aleksandar's code didn't work with the trigger I showed, but I tried a different one and it woked. What I think was happening was that the spel was triggered before the status changes were written in the database. Being so, the counter always showed one less completed task.

     

    Changing the trigger to a POST_CI with the cr_id as an argument did the trick. Working 100%. Thank you very much!

    OBJECT cr_wf {
        TRIGGERS {
            POST_CI z_tsk_comp_jv(cr) 12030
                FILTER( status { -> 'APP'} || status { -> 'COMP'});
        };
    };