SPEL EVENT methods

Document created by Gutis Champion on Oct 28, 2015Last modified by Gutis Champion on Oct 28, 2015
Version 3Show Document
  • View in full screen mode

SPEL EVENT methods

 

I was investigating bopevt.maj files for the new spel methods to use, when i found the following Warnings:

//    Do not attempt to directly delete this object.  instead call

//    'cancel_me' with the object checked out.  The object may set a

//    state flag or it may delete itself.

//

//    WARNING  It is not recommended to just make one of these.  It is

//    better to use the Event methods to create one for you  Sequence

//    of setting attributes the first time is imprtant.

 

 

I always use cancel_me method to cancel events, but for inserting them to atev table i always used generic method that inserts them directly into atev. So i decided to investigate those methods.

This document describes those methods that should be used for inserting and canceling attached events.

 

new_attached_event

Definition:

 

new_attached_event ( object | nil ,string,string,duration | nil, date | nil,  string | nil, int, int, string timezone);

 

object - you can pass here top_object object. More information can be found here https://communities.ca.com/message/241836353#241836353

string - persid of the object to attach to

string - event sym

duration - owerwrite standard delay

date - owerwrite standard start time

string - atev group usualy SLA, or if you wan't to hide it empty string

int - attached_sla.id

int - if 1 event will be in status delayed

string - time zone

 

Working example:

This code will insert an event with start date now, event delay will be overwrited to 2 min. Event wil be not visible in Service Type tab, so user will have no possibility to cancel it. This example uses top_object object

duration timeout;
timeout = 120;
object group_leader;
  send_wait(0, top_object(), "get_co_group");
    if (msg_error()) {
        printf("Error'%s'", msg[0]);
        return;
    }
else{
    group_leader = msg[0];

send_wait(0, top_object(), "call_attr", "evt", "new_attached_event", group_leader, "chg:400896","1hr chg unassigned", timeout ,now(), "SLA", 0, 0,"UTC");
if (msg_error()) {
printf("Error %s",msg[0]);
}
}
send_wait(0, group_leader, "checkin");
    if (msg_error()) {
        printf("Error'%s'", msg[0]);
    }




 

new_attached_event_obj

Definition:

 

new_attached_event_obj ( object | nil ,string,object,duration | nil, date | nil,  string | nil, int, int, string timezone);

 

object - you can pass here top_object object. More information can be found here https://communities.ca.com/message/241836353#241836353

string - persid of the object to attach to

object - event object to insert

duration - owerwrite standard delay

date - owerwrite standard start time

string - atev group usualy SLA, or if you wan't to hide it empty string

int - attached_sla.id

int - if 1 event will be in status delayed

string - time zone

 

Working example

This will insert an event with default start and delay time, event will be visible in Service Type tab

duration timeout;
date startdate;
object Objevt;

send_wait(0, top_object(), "call_attr", "evt", "dob_by_persid", 0, "evt:12202");
if (msg_error()) {
printf("Error %s",msg[0]);
}
else
{
  Objevt = msg[0];
  send_wait(0, top_object(), "call_attr", "evt", "new_attached_event_obj", NULL, "chg:400619",Objevt, timeout ,startdate, "SLA", 0, 0,"UTC");
  if (msg_error()) {
  printf("Error %s",msg[0]);
  }
}


 

cancel_me

 

Definition:

 

cancel_me()

 

Takes no arguments but needs to be run on particular attached event. Event needs to be checked out

 

Working example (much better example, provided by cdtj, can be found here: https://communities.ca.com/message/241810464#241810464)

send_wait(0, top_object(), "call_attr", "atev", "dob_by_persid", 0, "atev:400054");
if (msg_error()) {
printf("Error %s",msg[0]);
}
else
{
object evtObj, gl;
evtObj = msg[0];
printf(evtObj.cancel_time);

send_wait(0, top_object(), "get_co_group");
      if (msg_error()) {
           logf(ERROR, "Error : %s", msg[0]);
           return;
      }
      gl = msg[0];
   send_wait(0, gl, "checkout", evtObj);
      if (msg_error()) {
           logf(ERROR, "Error : %s", msg[0]);
           return;
      }

send_wait(0, evtObj, "cancel_me");
  if (msg_error()) {
  printf("Error %s",msg[0]);
  }

send_wait(0, gl, "checkin");
       if (msg_error()) {
            logf(ERROR, "Error : %s", msg[0]);
            send_wait(0, gl, "uncheck");
            return;
       }

}


2 people found this helpful

Attachments

    Outcomes