Propagate Solution to Children
To discuss or ask questions about this article, select the discussion tab above.
Overview
This article provides instructions for being able to log a Solution on a Parent ticket and being able to post that solution for all the child tickets as well.
This customization was designed for the r11.x releases, and is untested in older releases.
Notice: Solutions marked as internal are not recognized as solutions and do not fulfill the solution requirement. It is recommended that you remove the internal checkbox for Solution entry.
Benefits
- All Solutions can be passed from Parent to Children.
- The Child Activity Logs are annotated with syntax stating that the Solution was initiated by the Parent.
- Users have an option per Solution whether to propagate to the Children or not.
Procedures
Step 1. Create the script
A script is created as an .spl file and placed in the $NX_ROOT/site/mods/majic directory. When the Service Desk service starts, the contents of the majic directory are processed and cached. You can use any naming scheme you like for your .spl file, but it is recommended that the file be preceded with a 'z' for easy identification as a custom file (eg zMyCompany.spl, zcr_scripts.spl, zMyScripts.spl).
<source lang="javascript">alg::zsoln_to_child(...) { string c_desc, c_num, c_persid, c_type, p_num, p_type, wc; object c_dob, c_list, group_leader, act_log_table_record; int c_count, i;
p_num = call_req_id.ref_num; p_type = call_req_id.type.sym; wc = format("parent = '%s'", call_req_id);
send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "MLIST_STATIC", wc, -1,0); c_count = msg[1]; c_list = msg[0]; if (c_count > 0) { for(i=0;i< c_count;i++) { send_wait(0, top_object(), "get_co_group"); group_leader = msg[0];
send_wait(0, c_list, "dob_by_index", "DEFAULT", i, i); c_dob = msg[0];
send_wait(0, c_dob, "get_attr_vals",3,"ref_num","type.sym", "persistent_id"); c_num = msg[3]; c_type = msg[6]; c_persid = msg[9]; c_desc = description + " (initiated from Parent " + p_type + " " + p_num + ")" ;
send_wait(0, top_object(), "call_attr", "alg", "get_new_dob", NULL, NULL, group_leader); act_log_table_record = msg[0]; act_log_table_record.action_desc = action_desc; act_log_table_record.call_req_id = c_persid; act_log_table_record.description = c_desc; act_log_table_record.internal = internal; act_log_table_record.time_spent = 0; act_log_table_record.type = type; send_wait(0, group_leader, "checkin"); if (msg_error()) { logf(ERROR, "error adding solution on Child %s %s from Parent %s %s - %s", c_type, c_num, p_type, p_num, msg[0]); } else { logf(SIGNIFICANT, "successfully added solution on Child %s %s from Parent %s %s", c_type, c_num, p_type, p_num); send_wait(0, group_leader, "checkout", c_dob); last_mod_dt = (int)now(); send_wait(0, group_leader, "checkin"); if (msg_error()) { logf(ERROR, "error updating last_mod_dt on %s %s - %s", c_type, c_num, msg[0]); } else { logf(SIGNIFICANT, "successfully updated last_mod_dt on %s %s", c_type, c_num); } } } } }</source>
Step 2. Create the trigger
This step is to create the trigger that will initiate the script. Use the Schema Designer utility to add the following code as a Site-Defined Trigger to the alg (Request Activity Log) table. <source lang="javascript">POST_VALIDATE zsoln_to_child() 111 FILTER(type{-> 'SOLN'} && zset_child_f == 1 );</source> This trigger will activate when the Solution (SOLN) Activity is initiated.
Step 3. Add field to Object Engine
This step creates a field that exists only in the Object Engine which means it doesn't have a dedicated field in the database. Make this change by creating a .mod file and placing it in the $NX_ROOT/site/mods/majic directory. Name the .mod anything you like, but it is recommended that it be preceded with a 'z'. The Web Screen Painter cannot be used for making Object Engine fields. Implementing this field adds an option to allow someone to determine if the Status should be propagated from Parent to Children on an as needed basis.
<source lang="text">OBJECT alg {
ATTRIBUTES Act_Log {
zset_child_f LOCAL INTEGER { ON_DB_INIT SET 0 ; } ;
};
};</source> Note: If the Propagate Status to Children customization is implemented there is no need to add the zset_child_f field.
Step 4. Edit the detail_alg.htmpl form
This step will add a checkbox giving the option to propagate the Solution to children. Add the following code:<source lang="javascript"><PDM_IF "$args.alg.type" == "SOLN" && $args.children.length > 0 > <PDM_MACRO NAME=dtlCheckbox hdr="Propagate to Children?" attr=alg.zset_child_f> </PDM_IF></source>
Note: The <PDM_IF> prevents the checkbox from appearing if there are no children as well as ensures that it only appears for the Solution Activity. Other conditions can be added to the <PDM_IF> if this capability should have more restricted use.
Step 5. Publish the Schema changes
Follow these steps for publishing the schema changes:
- Save and Publish your Schema changes
- Stop the Service Desk service
- Run pdm_publish from a command line
- Start the Service Desk service