CA Service Management

Expand all | Collapse all

on log comment, status change update cr

  • 1.  on log comment, status change update cr

    Posted 09-08-2018 02:20 PM

    Hello Guys

     

    I want to update the custom date field in cr object from alg. Post_validate alg object for type =log, st, tr.

     

    My mod and spell as follows

     

    MODIFY alg POST_VALIDATE znowalg_update() 5011 FILTER(type=="LOG" || type=="ACK" || type=="RE" || type=="ESC" || type=="ST" || type=="TR" );

    -----------------------------------------------------

    alg::znowalg_update (...){
    object c_dob, c_list, group_leader, act_log_table_record;
    int cur_time;
    cur_time = now();

    send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");

    who=msg[0];

    send_wait(0, top_object(), "call_attr", "api", "update_object", who, c_dob.persistent_id, NULL, group_leader, 0, "zalgnow_upd", cur_time);

    send_wait(0, group_leader, 'checkin');

     

    }

    But I am getting error on changing anything in the ticket.

    09/08 22:54:58.38 WWL-DT-SD-01 spelsrvr 10768 ERROR pcexec.c 6123 Spell interp failed at znowalg_update.spl:11:alg::znowalg_update: No object for member variable persistent_id

     

    Any ideas.

     

    Thanks

    MM



  • 2.  Re: on log comment, status change update cr

    Posted 09-09-2018 02:49 AM

    Hi,

    in your example c_dob is not defined.

    As cr is checked out on alg insert, you can try this one:

    alg::znowalg_update (...){
        send_wait(0, this, "call_attr", "call_req_id.zalgnow_upd", "set_val", now(), "SURE_SET");
    }

    or even use QREL/BREL to fetch latest activity's time_stamp/system_time.

    or use htmpl form to pass user's local time, example: 

    <PDM_IF "$args.producer_id" == "alg">
        document.write('<input name="SET.call_req_id.zalgnow_upd" value="' + Math.round(Date.now() / 1000) + '">');
    <PDM_ELSE>
        document.write('<input name="SET.zalgnow_upd" value="' + Math.round(Date.now() / 1000) + '">');
    </PDM_IF>

    Regards.



  • 3.  Re: on log comment, status change update cr

    Posted 09-09-2018 05:13 AM

    Now , I am able to update the custom field every time when user uses log comment or status change or analyst change, or priority change.

    I want to use date difference between this date (i.e. last modified date by any above said methods) and current date. We required to send notification if time between last activity by analyst and current time reached 2 hours.

    I have configured external php script to update date difference from above date in minutes and updated in integer zdatediff column after every 2 minutes. Also added new zdatediff column in activity association. And added condition that  if zdatediff>120  in event and delay 0 hours and repeat delay is 2 hours then notification will be sent.

    But event condition only  checks at ticket logging , if it didnt find condition true, it's not checking the condition on repeat delay.

     

    Is there any other way to configure notification if last_updateactivity and now time increases 2 hours?

     

    Thanks

    MM



  • 4.  Re: on log comment, status change update cr

    Posted 09-09-2018 08:17 AM

    you need to extend script a bit:

    alg::znowalg_update (...){
         if (!is_empty(call_req_id.zalgnow_upd) && !is_null(call_req_id.zalgnow_upd)) {
              date zLastUpd, zNow;
              zLastUpd = call_req_id.zalgnow_upd;
              zNow = now();
              logf(SIGNIFICANT, "%s > LastUpd: %s, Now: %s", persistent_id, zLastUpd, zNow);
              if ((int)zNow - (int)zLastUpd >= (2 * 3600)) {
                   // Attach an event with Multiple notification macro,
                   // no any conditions needed.
                   // OR trigger Multiple notification macro directly from spel.
              }
         }
         send_wait(0, this, "call_attr", "call_req_id.zalgnow_upd", "set_val", now(), "SURE_SET");
    }

    If you prefer event way, here is an example: SPEL EVENT methods 

    Directly calling macro is less flexible way but working faster: Check condition macro via spel (execute method works same for Action/Multiple notification macros as well).

     

    PS: To avoid possible access conflicts youd better to rewrite line4 with send_wait get_val method expcept of plain assignment.



  • 5.  Re: on log comment, status change update cr

    Posted 09-09-2018 11:16 AM

    Thanks cdtj for the quick response, But one thing I just want more clarification

              if ((int)zNow - (int)zLastUpd >= (2 * 3600)) {
                   // Attach an event with Multiple notification macro,
                   // no any conditions needed.
                   // OR trigger Multiple notification macro directly from spel

     

    If I will add event in above condition then this event will fire only at the condition given in POST_VALIDATE i.e. log comment, update status, Transfer, escalate. But in all conditions it will not cross the 2 hours difference as just now any of these activities performed.

    It should check after 2 hours whether this condition met or not 

       if ((int)zNow - (int)zLastUpd >= (2 * 3600)) {

     

    Is there any way to wait this condition or adding event but event will check the condition after 2 hours not at the time of adding this event? Like if after 2 hours, condition didnt met then it will not send an notification.

     

    Thanks

    MM



  • 6.  Re: on log comment, status change update cr

    Posted 09-09-2018 11:33 AM

    Maybe I missed something, please correct me if so. So you want to perform a check after 2 hours to check that some activity performed or not?

    If yes you can attach an event with mulitiple notification and condition like this:

    if (!is_empty(call_req_id.zalgnow_upd) && !is_null(call_req_id.zalgnow_upd)) {
         if ((int)now() - (int)zalgnow_upd <= (2 * 3600)) {
              set_return_data(FALSE); // activity performed within 2h
              return;
         }
    }
    set_return_data(TRUE); // no activity performed


  • 7.  Re: on log comment, status change update cr

    Posted 09-09-2018 11:54 AM

    Hi,

     

    This condition will always return false as it will check only when any activity performed. Please look at the post_validate condition that only when any activity performed. So this condition always gives 0 difference.

    Never true condition will have in spell.

     

    Thanks

     

    Thanks & Regards

    Mayur Malhotra