<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://greggsmith.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ribru02</id>
		<title>SDU - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://greggsmith.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ribru02"/>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=Special:Contributions/Ribru02"/>
		<updated>2026-07-29T16:53:48Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.1</generator>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4306</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4306"/>
				<updated>2011-02-11T09:46:43Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; SPELL - Cancel and Add events based on the scheduling time in CO in ServiceDesk Manager R12.5&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one that fires at 50% of the scheduled time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
'''STEP1'''&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/mods/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''STEP2'''&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/mods/majic with the following code and kill the process spel_srv or restart the servicedesk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        //UPDATE YOUR EVENTS HERE&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4305</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4305"/>
				<updated>2011-02-11T09:31:39Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; SPELL - Cancel and Add events based on the scheduling time in CO in ServiceDesk Manager R12.5&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one that fires at 50% of the scheduled time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
'''STEP1'''&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''STEP2'''&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/majic with the following code and kill the process spel_srv or restart the servicedesk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        //UPDATE YOUR EVENTS HERE&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4304</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4304"/>
				<updated>2011-02-11T09:30:35Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; SPELL - Cancel and Add events based on the scheduling time in CO in ServiceDesk Manager R12.5&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one at 50% of the time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
'''STEP1'''&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''STEP2'''&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/majic with the following code and kill the process spel_srv or restart the servicedesk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        //UPDATE YOUR EVENTS HERE&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4303</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4303"/>
				<updated>2011-02-11T09:28:28Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; SPELL - Cancel and Add events based on the scheduling time in CO in ServiceDesk Manager R12.5&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one at 50% of the time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
'''STEP1'''&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''STEP2'''&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/majic with the following code and kill the precess spel_srv or restart the servicedesk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        //UPDATE YOUR EVENTS HERE&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4302</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4302"/>
				<updated>2011-02-11T09:27:06Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; SPELL - Cancel and Add events based on the scheduling time in CO &lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one at 50% of the time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
'''STEP1'''&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''STEP2'''&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/majic with the following code and kill the precess spel_srv or restart the servicedesk:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4301</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4301"/>
				<updated>2011-02-11T09:24:53Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SPELL - Cancel and Add events based on the scheduling time in CO ==&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one at 50% of the time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;	text&amp;quot;&amp;gt;   &lt;br /&gt;
OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&amp;lt;/source lang&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4300</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4300"/>
				<updated>2011-02-11T09:22:45Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;   OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;SPELL&amp;quot;&amp;gt;&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:              z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:             10-02-2011&lt;br /&gt;
// Author:              ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//        Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time)&lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
        duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
        string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
        object atev_dob, atev_list, group_leader;&lt;br /&gt;
        string persistent_id,method;&lt;br /&gt;
        string wc;&lt;br /&gt;
        int atev_count, i;&lt;br /&gt;
&lt;br /&gt;
        method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
&lt;br /&gt;
        persistent_id=argv[3];&lt;br /&gt;
        schedule_start_date_old = argv[5];&lt;br /&gt;
        schedule_start_date_new = argv[6];&lt;br /&gt;
        duration_schedule_old = argv[11];&lt;br /&gt;
        duration_schedule_new = argv[12];&lt;br /&gt;
        event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
        event_name_50_tmpl_persid=&amp;quot;evt:7649776&amp;quot;;&lt;br /&gt;
        event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
        event_name_75_tmpl_persid=&amp;quot;evt:7649777&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (DEBUG == 2) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_nuu&lt;br /&gt;
m, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
        //getting group leader&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
                group_leader = msg[0];&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //calculation metrics&lt;br /&gt;
        //fire 50% and new event fire 75% of time duration&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
                duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //debug Info&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        //remove existing events before adding new ones&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
            // Identify the persids of the events to be deleted.&lt;br /&gt;
                wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id);&lt;br /&gt;
                send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
                atev_list = msg[0];&lt;br /&gt;
                atev_count = msg[1];&lt;br /&gt;
                if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
                if (atev_count &amp;gt; 0) {&lt;br /&gt;
                        for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
                                send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
                                atev_dob = msg[0];&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
                                send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
                                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                                if (msg_error())&lt;br /&gt;
                                {&lt;br /&gt;
                                         logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
                                }&lt;br /&gt;
                                else&lt;br /&gt;
                                {&lt;br /&gt;
                                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
                                }&lt;br /&gt;
                        }&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
        // Add events 50% and 75% of the duration time&lt;br /&gt;
        ////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_50,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date  &lt;br /&gt;
%s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_new);&lt;br /&gt;
                send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
                if (msg_error())&lt;br /&gt;
                {&lt;br /&gt;
                        logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                        send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                        if (DEBUG == 2) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
        if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4299</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4299"/>
				<updated>2011-02-11T09:13:38Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;   OBJECT chg {&lt;br /&gt;
        TRIGGERS {&lt;br /&gt;
        POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
        };&lt;br /&gt;
    };&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4298</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4298"/>
				<updated>2011-02-11T09:12:05Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{&lt;br /&gt;
OBJECT chg {&lt;br /&gt;
  TRIGGERS {&lt;br /&gt;
    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
  };&lt;br /&gt;
};&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4297</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4297"/>
				<updated>2011-02-11T09:11:30Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: Replacing page with 'OBJECT chg {
  TRIGGERS {
    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; ac...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OBJECT chg {&lt;br /&gt;
  TRIGGERS {&lt;br /&gt;
    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
  };&lt;br /&gt;
};&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4296</id>
		<title>SPELL CODE to to add event at 50% and 75% of the time between schedule start time and duration</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=SPELL_CODE_to_to_add_event_at_50%25_and_75%25_of_the_time_between_schedule_start_time_and_duration&amp;diff=4296"/>
				<updated>2011-02-11T09:05:28Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: SPELL - Cancel and Add events based on the scheduling time in CO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SPELL - Cancel and Add events based on the scheduling time in CO&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This code add 2 events to CO one at 50% of the time and another at 75%.&lt;br /&gt;
&lt;br /&gt;
The 50% starts at sched_start_time and fires at sched_start_time + duration /2&lt;br /&gt;
The 75% starts at sched_start_time and fires at  sched_start_time + duration /4*3&lt;br /&gt;
&lt;br /&gt;
Whenever there is a change this code check if there are similar events and cancel them.&lt;br /&gt;
&lt;br /&gt;
Trigger to add, create a z_my_event_sched_end_date.mod and put at $NX_ROOT/site/majic with the following code, and restart the service desk:&lt;br /&gt;
&lt;br /&gt;
OBJECT chg {&lt;br /&gt;
  TRIGGERS {&lt;br /&gt;
    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
  };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SPELL code  create a z_my_event_sched_end_date.spl and put at $NX_ROOT/site/majic with the following code and kill the precess spel_srv or restart the servicedesk:&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Module:		z_my_event_sched_end_date.spl&lt;br /&gt;
// Created:		10-02-2011&lt;br /&gt;
// Author:		ribru02@ca.com&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Description:&lt;br /&gt;
//&lt;br /&gt;
//    Spel to add event when sched_duration or sched_start_date are inserted or updated&lt;br /&gt;
//    Add and remove fixed events. Add 2 events one to advise at 50% of the elapsed time and other for 75% of the elapsed time&lt;br /&gt;
//	  Starting the event at sched_start_time delaying it duration/2 (50% between start and end sechduled time) &lt;br /&gt;
//    Starting the event at sched_start_time  and  delaying it duration/4*3 (75% between start and end sechduled time)&lt;br /&gt;
//&lt;br /&gt;
//Fired with the following trigger:&lt;br /&gt;
//OBJECT chg {&lt;br /&gt;
//  TRIGGERS {&lt;br /&gt;
//    POST_VALIDATE z_my_event_sched_end_date( persistent_id, sched_start_date, sched_end_date, sched_duration) 250 FILTER( EVENT(&amp;quot;INSERT UPDATE&amp;quot;) &amp;amp;&amp;amp; active != 0 &amp;amp;&amp;amp; sched_start_date != NULL &amp;amp;&amp;amp; sched_duration &amp;gt;0);&lt;br /&gt;
//  };&lt;br /&gt;
//};&lt;br /&gt;
//&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//History&lt;br /&gt;
//v1.0 - ribru02@ca.com - First version&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
#define  VERSION &amp;quot;v1.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// DEBUG 0 for no debug&lt;br /&gt;
// DEBUG 1 for debug&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define DEBUG 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
chg::z_my_event_sched_end_date (...)&lt;br /&gt;
{&lt;br /&gt;
	&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//vars&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
	date schedule_start_date_old,schedule_start_date_new, schedule_start_date_75;&lt;br /&gt;
	duration duration_schedule_old,duration_schedule_new, duration_50, duration_75;&lt;br /&gt;
	string event_name_50, event_name_75, event_name_50_tmpl_persid,event_name_75_tmpl_persid;&lt;br /&gt;
	object atev_dob, atev_list, group_leader;&lt;br /&gt;
	string persistent_id,method;&lt;br /&gt;
	string wc;&lt;br /&gt;
	int atev_count, i;&lt;br /&gt;
	&lt;br /&gt;
	method  = &amp;quot;z_my_event_sched_end_date&amp;quot;+&amp;quot;_&amp;quot;+ VERSION;&lt;br /&gt;
	&lt;br /&gt;
	persistent_id=argv[3];&lt;br /&gt;
	schedule_start_date_old = argv[5];&lt;br /&gt;
	schedule_start_date_new = argv[6];&lt;br /&gt;
	duration_schedule_old = argv[11];&lt;br /&gt;
	duration_schedule_new = argv[12];&lt;br /&gt;
        //'''Bold text'''ADD YOUR EVENTS INFORMATION HERE'''Bold text'''&lt;br /&gt;
	event_name_50= &amp;quot;Increase Priority base on scheduled time 50%&amp;quot;;&lt;br /&gt;
	event_name_50_tmpl_persid=&amp;quot;evt:400001&amp;quot;; &lt;br /&gt;
	event_name_75= &amp;quot;Increase Priority base on scheduled time 75%&amp;quot;;&lt;br /&gt;
	event_name_75_tmpl_persid=&amp;quot;evt:400002&amp;quot;;&lt;br /&gt;
	&lt;br /&gt;
        &lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//Previous validation&lt;br /&gt;
//If there is no change in one of the field there is no calculation&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////		&lt;br /&gt;
	&lt;br /&gt;
if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== START : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
if (!((schedule_start_date_old == schedule_start_date_new) &amp;amp;&amp;amp; (duration_schedule_old == duration_schedule_new)))&lt;br /&gt;
{&lt;br /&gt;
	//getting group leader	&lt;br /&gt;
		send_wait(0, top_object(), &amp;quot;get_co_group&amp;quot;);&lt;br /&gt;
		group_leader = msg[0];&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
	//calculation metrics&lt;br /&gt;
	//fire 50% and new event fire 75% of time duration&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
		duration_50=(duration)((int)duration_schedule_new/2);&lt;br /&gt;
		duration_75=(duration)((int)duration_schedule_new/4*3);&lt;br /&gt;
		&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////	&lt;br /&gt;
	//debug Info&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
		&lt;br /&gt;
		if (DEBUG) logf(SIGNIFICANT,&amp;quot;%s - CO nº %s - NºArgs: %s =&amp;gt; %s = %s -&amp;gt; %s| %s = %s -&amp;gt; %s | %s = %s -&amp;gt; %s &amp;quot;, method, chg_ref_num, argv[0],argv[4], argv[5], argv[6], argv[7],argv[8], argv[9], argv[10], argv[11],argv[12]);&lt;br /&gt;
		&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////	&lt;br /&gt;
	//remove existing events before adding new ones&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////	&lt;br /&gt;
	 &lt;br /&gt;
	    // Identify the persids of the events to be deleted.&lt;br /&gt;
		wc = format(&amp;quot;(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s' AND status_flag = 2&amp;quot;, event_name_50_tmpl_persid,event_name_75_tmpl_persid,persistent_id); &lt;br /&gt;
		send_wait(0, top_object(), &amp;quot;call_attr&amp;quot;, &amp;quot;atev&amp;quot;, &amp;quot;sync_fetch&amp;quot;, &amp;quot;STATIC&amp;quot;, wc, -1, 0);&lt;br /&gt;
		atev_list = msg[0];&lt;br /&gt;
		atev_count = msg[1];&lt;br /&gt;
	 	if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - need to cancel %s event for CO %s&amp;quot;, method, atev_count,chg_ref_num);&lt;br /&gt;
		if (atev_count &amp;gt; 0) {&lt;br /&gt;
			for (i=0;i&amp;lt;atev_count;i++) {&lt;br /&gt;
				send_wait(0, atev_list, &amp;quot;dob_by_index&amp;quot;, &amp;quot;DEFAULT&amp;quot;, i, i);&lt;br /&gt;
				atev_dob = msg[0];&lt;br /&gt;
				send_wait(0, group_leader, &amp;quot;checkout&amp;quot;, atev_dob);&lt;br /&gt;
				send_wait(0, atev_dob, &amp;quot;cancel_me&amp;quot;);&lt;br /&gt;
				send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
				if (msg_error()) &lt;br /&gt;
				{&lt;br /&gt;
					 logf(ERROR, &amp;quot;%s - error cancelling event for CO %s - %s&amp;quot;, method, chg_ref_num, msg[0]);&lt;br /&gt;
				} &lt;br /&gt;
				else &lt;br /&gt;
				{&lt;br /&gt;
					if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully canceled event for CO %s&amp;quot;, method, chg_ref_num);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////	&lt;br /&gt;
	// Add events 50% and 75% of the duration time&lt;br /&gt;
	////////////////////////////////////////////////////////////////////////////////	&lt;br /&gt;
		schedule_start_date_75 = (date)((duration)schedule_start_date_new + duration_50);	&lt;br /&gt;
		send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_50,(duration)duration_50,(date)schedule_start_date_new,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
		if (msg_error()) &lt;br /&gt;
		{&lt;br /&gt;
		 	logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - Command executed in CO nº: %s to add event: %s - duration: %s - start_date %s&amp;quot;,  method, chg_ref_num,event_name_75,(duration)duration_75,(date)schedule_start_date_75);&lt;br /&gt;
		send_wait(0,top_object(),&amp;quot;call_attr&amp;quot;,&amp;quot;evt&amp;quot;,&amp;quot;new_attached_event&amp;quot;, group_leader,persistent_id,event_name_75,(duration)duration_75,(date)schedule_start_date_75,&amp;quot;INCPRI&amp;quot;,0,0,&amp;quot;&amp;quot;);&lt;br /&gt;
		if (msg_error()) &lt;br /&gt;
		{&lt;br /&gt;
		 	logf(ERROR, &amp;quot;%s - error new_attached_event failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - successfully new_attached_event for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		send_wait(0, group_leader, &amp;quot;checkin&amp;quot;);&lt;br /&gt;
		if (msg_error()) &lt;br /&gt;
		{&lt;br /&gt;
		 	logf(ERROR, &amp;quot;%s - Add event checkin failed for CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		 	send_wait(0, group_leader, &amp;quot;uncheck&amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if (DEBUG) logf(SIGNIFICANT, &amp;quot;%s - Add event checkin successfull CO %s - %s&amp;quot;,  method, chg_ref_num, msg[0]);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	if (DEBUG) logf(SIGNIFICANT,&amp;quot;=========== END : %s %s:%s ===========&amp;quot;,method,type,chg_ref_num);&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=Sample_Customizations&amp;diff=4295</id>
		<title>Sample Customizations</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=Sample_Customizations&amp;diff=4295"/>
				<updated>2011-02-11T08:56:37Z</updated>
		
		<summary type="html">&lt;p&gt;Ribru02: /* List of Customizations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Customization]]&lt;br /&gt;
{{Global Header}}&lt;br /&gt;
{{Global Announcement}}&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
Customizations are regarded as changes to the system that are not supportable by CA.&lt;br /&gt;
&lt;br /&gt;
== List of Customizations ==&lt;br /&gt;
[[image:exclaim.gif]][[SDU:SDU r12 EP1|SDU Enhancement Pack 1 for r12]]&lt;br /&gt;
*[[Action Macro to Log Solution and Resolve Ticket]]&lt;br /&gt;
*[[Add Checkbox, Date, Drop-down, Lookup, Readonly and Text Fields to Properties]]&lt;br /&gt;
*[[Add Contact Search to Employee/Customer Interface]]&lt;br /&gt;
*[[Add Custom Activity Log Action Macro]]&lt;br /&gt;
*[[Add Log Entry for Updates to Custom Fields]]&lt;br /&gt;
*[[Add Log Entry When a Property Value Changes on a Ticket]]&lt;br /&gt;
*[[Add Personalized Response to Manual Notification]]&lt;br /&gt;
*[[Add Posted By to Announcements Page]]&lt;br /&gt;
*[[Add Properties Count to Area/Category List]]&lt;br /&gt;
*[[Add Ticket and CI Links to Announcements]]&lt;br /&gt;
*[[Add Workflow to Employee/Customer Interface]]&lt;br /&gt;
*[[Attachments on Configuration Items]]&lt;br /&gt;
*[[Attachments on Contacts]]&lt;br /&gt;
*[[Auto-fill Fields Left Blank]]&lt;br /&gt;
*[[Automatically Attach an Asset/CI to a Change Order or Issue]]&lt;br /&gt;
*[[Automatically Remove Attached Events]]&lt;br /&gt;
*[[Automatically Set Assignee to Closing Analyst]]&lt;br /&gt;
*[[Automatically Set System Generated Activities to Internal]]&lt;br /&gt;
*[[Changing Announcements Order By]]&lt;br /&gt;
*[[Changing Error Alert Color and adding Error Alert Pop-ups]]&lt;br /&gt;
*[[Changing Requests to Incidents]]&lt;br /&gt;
*[[Changing Display of Contacts]]&lt;br /&gt;
*[[Conditional Display of Drop-Down Content]]&lt;br /&gt;
*[[Conditionally Attach an Event]]&lt;br /&gt;
*[[Control the Request Areas Displayed to the End Users]]&lt;br /&gt;
*[[Count Ticket Reopens]]&lt;br /&gt;
*[[Custom Lookup method for TextAPI]]&lt;br /&gt;
*[[Displaying the System and User Descriptions in the Activity Log]]&lt;br /&gt;
*[[Display Web Site within Service Desk]]&lt;br /&gt;
*[[Default Properties Tab on New Ticket Creation]]&lt;br /&gt;
*[[Generate Notifications Only for Employee Comments]]&lt;br /&gt;
*[[Increasing Default Field Size]]&lt;br /&gt;
*[[List Tickets ORDER BY Group]]&lt;br /&gt;
*[[Make a Field Conditionally Required]]&lt;br /&gt;
*[[Modify Action and Condition Macros via the GUI]]&lt;br /&gt;
*[[Only Assignee can Close]]&lt;br /&gt;
*[[Prevent Close of Requests/Incidents/Problems if Change Order is Active]]&lt;br /&gt;
*[[Prevent Update to Past Activities]]&lt;br /&gt;
*[[Propagate Solution to Children]]&lt;br /&gt;
*[[Propagate Status to Children]]&lt;br /&gt;
*[[Priority and Impact Default to Empty]]&lt;br /&gt;
*[[Refresh Customer Info Before Saving the Ticket]]&lt;br /&gt;
*[[Remove Second Message on Timeout]]&lt;br /&gt;
*[[Remove SLA Violation from Employee View]]&lt;br /&gt;
*[[Require a Solution in Order to Resolve]]&lt;br /&gt;
*[[Require Assignee to be a Member of the selected Group]]&lt;br /&gt;
*[[Search Requests, Incidents, and Problems Simultaneously for Ticket Number]]&lt;br /&gt;
*[[Send Notification at Callback Time]]&lt;br /&gt;
*[[Send Notification to CI's Attached Contacts]]&lt;br /&gt;
*[[Send Survey based on Variables]]&lt;br /&gt;
*[[Separate Prefixes for Requests, Incidents, and Problems]]&lt;br /&gt;
*[[Set Defaults on Manual Notify]]&lt;br /&gt;
*[[Set Priority Based on Urgency and Impact]]&lt;br /&gt;
*[[Set Request/Incident/Problem Status from Change Order]]&lt;br /&gt;
*[[Set Request/Incident/Problem Status on Dispatch Change]]&lt;br /&gt;
*[[Simplified Child Creation]]&lt;br /&gt;
*[[Single Sign-on with Cookies]]&lt;br /&gt;
*[[EIAM Services dont start on fresh install]]&lt;br /&gt;
*[[SPELL CODE to Make ACT / EVT INTERNAL]]&lt;br /&gt;
*[[SPELL CODE to to add event at 50% and 75% of the time between schedule_start_time and duration ]]&lt;/div&gt;</summary>
		<author><name>Ribru02</name></author>	</entry>

	</feed>