TMACUL

http://www.servicedeskusers.com/Add_Log_Entry_When_a_Property_Value_Changes_on_a_Ticket.

Blog Post created by TMACUL Champion on Jan 1, 2016

Add Log Entry When a Property Value Changes on a Ticket

 

From SDU

Jump to: navigation, search

 

To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.


 

Overview

This article provides instructions for adding entries to the Activity Log when a property value changes on a ticket. The steps involved are creating a new Activity Notification, adding Site-Defined Triggers, and writing SPEL code for functions used by the the triggers.

Procedures

Step 1. Create the Activity Notification

Create a new Activity Notification, “Property Update” in USD Web Client. It can be done by copying an existing Activity Notification, "Field Update" via File | Copy menu option. Use the code "PROP" for the new activity. This code will be used in the SPEL code when specifying log type:

alg.type = "PROP"; chgalg.type = "PROP"; issalg.type = "PROP";

Step 2. Create the spell file

Create a spel file prop_log.spl in $NX_ROOT\site\mods\majic folder. Note: if you change the name of the spel file, change the name of the dummy function in the beginning of the spel file accordingly

//  Dummy function, just so RCS Id is embedded in compiled spell file... string prp_log_spl_RCSID() { return "@(#)$Id: prp_log.spl,v 1.00 2007/21/0 21:54:25 lauke01 Exp $"; }   // Request property cr_prp::zlog_value_change(...) { string ME; ME = "cr_prp::zlog_value_change";   string prp_persid, cr_persid, old_val, new_val, zzlabel, zzsequence;   prp_persid = argv[3]; cr_persid = argv[6]; old_val = argv[8]; new_val = argv[9]; zzlabel = argv[12]; zzsequence = argv[15];   send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, cr_persid); if (msg_error()) { logf (ERROR, "%s: could not get dob for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); return; } object dob; dob = msg[0];   send_wait(0, top_object(), "get_co_group"); if (msg_error()) { logf (ERROR, "%s: could not get group leader for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); return; } object group_leader; group_leader = msg[0];   send_wait(0, group_leader, "checkout", dob); if (msg_error() && msg[0] != "NO") { logf(ERROR, "%s: checkout failed for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); return; }   send_wait(0, dob, "call_attr", "log_agent", "get_val"); if (msg_error()) { logf (ERROR, "%s: could not get log agent for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); return; } uuid log_agt; log_agt = msg[0];   object alg; send_wait( 0, top_object(), "call_attr", "alg", "get_new_dob", NULL, NULL, group_leader); if (msg_error()) { logf (ERROR, "%s: could not get new alg for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); return; }   alg = msg[0]; alg.type = "PROP"; // Code that identifies "Property Update" Activity Notification alg.description = format("FIELD='property' LABEL='%s' SEQUENCE='%s' OLD='%s' NEW='%s'", zzlabel,zzsequence,old_val,new_val); alg.time_spent = "00:00:00"; alg.call_req_id = cr_persid; alg.analyst = log_agt; alg.system_time = (int)now(); alg.last_mod_dt = (int)now();   send_wait(0, group_leader, "checkin"); if (msg_error()) { logf(ERROR, "%s: checkin failed for cr=%s property=%s: %s", ME, cr_persid, zzsequence, msg[0]); send_wait(0, group_leader, "uncheck"); return; } }   // Change Order property prp::zlog_value_change(...) { string ME; ME = "prp::zlog_value_change";   string prp_persid, chg_id, chg_persid, old_val, new_val, zzlabel, zzsequence;   prp_persid = argv[3]; chg_id = argv[6]; chg_persid = format("chg:%s",chg_id); old_val = argv[8]; new_val = argv[9]; zzlabel = argv[12]; zzsequence = argv[15];   send_wait(0, top_object(), "call_attr", "chg", "dob_by_persid", 0, chg_persid); if (msg_error()) { logf (ERROR, "%s: could not get dob for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); return; }   object dob; dob = msg[0];   send_wait(0, top_object(), "get_co_group"); if (msg_error()) { logf (ERROR, "%s: could not get group leader for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); return; } object group_leader; group_leader = msg[0];   send_wait(0, group_leader, "checkout", dob); if (msg_error() && msg[0] != "NO") { logf(ERROR, "%s: checkout failed for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); return; }   send_wait(0, dob, "call_attr", "log_agent", "get_val"); if (msg_error()) { logf (ERROR, "%s: could not get log agent for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); return; } uuid log_agt; log_agt = msg[0];   object chgalg; send_wait( 0, top_object(), "call_attr", "chgalg", "get_new_dob", NULL, NULL, group_leader); if (msg_error()) { logf (ERROR, "%s: could not get new chgalg for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); return; }   chgalg = msg[0]; chgalg.type = "PROP"; // Code that identifies "Property Update" Activity Notification chgalg.description = format("FIELD='property' LABEL='%s' SEQUENCE='%s' OLD='%s' NEW='%s'", zzlabel,zzsequence,old_val,new_val); chgalg.time_spent = "00:00:00"; chgalg.change_id = chg_id; chgalg.analyst = log_agt; chgalg.system_time = (int)now(); chgalg.last_mod_dt = (int)now();   send_wait(0, group_leader, "checkin"); if (msg_error()) { logf(ERROR, "%s: checkin failed for chg=%s property=%s: %s", ME, chg_persid, zzsequence, msg[0]); send_wait(0, group_leader, "uncheck"); return; } }   // Issue property iss_prp::zlog_value_change(...) { string ME; ME = "iss_prp::zlog_value_change";   string prp_persid, iss_persid, old_val, new_val, zzlabel, zzsequence;   prp_persid = argv[3]; iss_persid = argv[6]; old_val = argv[8]; new_val = argv[9]; zzlabel = argv[12]; zzsequence = argv[15];   send_wait(0, top_object(), "call_attr", "iss", "dob_by_persid", 0, iss_persid); if (msg_error()) { logf (ERROR, "%s: could not get dob for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); return; } object dob; dob = msg[0];   send_wait(0, top_object(), "get_co_group"); if (msg_error()) { logf (ERROR, "%s: could not get group leader for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); return; } object group_leader; group_leader = msg[0];   send_wait(0, group_leader, "checkout", dob); if (msg_error() && msg[0] != "NO") { logf(ERROR, "%s: checkout failed for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); return; }   send_wait(0, dob, "call_attr", "log_agent", "get_val"); if (msg_error()) { logf (ERROR, "%s: could not get log agent for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); return; } uuid log_agt; log_agt = msg[0];   object issalg; send_wait( 0, top_object(), "call_attr", "issalg", "get_new_dob", NULL, NULL, group_leader); if (msg_error()) { logf (ERROR, "%s: could not get new issalg for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); return; }   issalg = msg[0]; issalg.type = "PROP"; // Code that identifies "Property Update" Activity Notification  issalg.description = format("FIELD='property' LABEL='%s' SEQUENCE='%s' OLD='%s' NEW='%s'", zzlabel,zzsequence,old_val,new_val); issalg.time_spent = "00:00:00"; issalg.issue_id = iss_persid; issalg.analyst = log_agt; issalg.system_time = (int)now(); issalg.last_mod_dt = (int)now();   send_wait(0, group_leader, "checkin"); if (msg_error()) { logf(ERROR, "%s: checkin failed for iss=%s property=%s: %s", ME, iss_persid, zzsequence, msg[0]); send_wait(0, group_leader, "uncheck"); return; } }

Step 3. Add the triggers

Using Schema Designer tool in Web Screen Painter, add the following site-defined triggers:

Table cr_prp (request property):

POST_CI zlog_value_change(persistent_id,owning_cr,value,label,sequence) 1050 FILTER(EVENT("UPDATE") && value {} );

Table iss_prp (issue property):

POST_CI zlog_value_change(persistent_id,owning_iss,value,label,sequence) 1050 FILTER(EVENT("UPDATE") && value {} );

Table prpr (change property):

POST_CI zlog_value_change(persistent_id,object_id,value,label,sequence) 1050 FILTER(EVENT("UPDATE") && value {} );

Step 4. Publish the Schema changes

The methods used to publish schema changes vary based on the Service Desk release.

For r11.x releases, follow these steps:

  1. Save your Schema changes
  2. Stop the Service Desk service
  3. Run pdm_publish from a command line
  4. Start the Service Desk service

For older releases recycle the Service Desk service.

Retrieved from "http://www.servicedeskusers.com/Add_Log_Entry_When_a_Property_Value_Changes_on_a_Ticket"

 

This page was last modified 05:24, 30 November 2010.  This page has been accessed 13,478 times.  Content is available under Attribution-Noncommercial-Share Alike 3.0 UnportedDisclaimers

Outcomes