Difference between revisions of "Propagate Status to Children"
m (→Step 1. Create the script) |
m |
||
| (23 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
[[Category:Customizations]] | [[Category:Customizations]] | ||
| + | [[Category:Incidents]] | ||
| + | [[Category:Problems]] | ||
| + | [[Category:Requests]] | ||
| + | [[Category:r11]] | ||
| + | [[Category:Schema Changes]] | ||
| + | [[Category:Spel Code]] | ||
{{Global Header}} | {{Global Header}} | ||
| + | {{Global Announcement}} | ||
== Overview == | == Overview == | ||
| Line 21: | Line 28: | ||
{{Create Spell Script}} | {{Create Spell Script}} | ||
| − | <source lang="javascript"> | + | <source lang="javascript">alg::zstat_to_child(...) { |
| − | + | string c_desc, c_num, c_origstatsym, c_type, p_num, p_stat, p_statsym, p_type, wc; | |
| − | + | object c_dob, c_list, group_leader; | |
| − | + | int c_count, i; | |
| − | + | uuid login_userid; | |
| − | + | ||
| − | + | p_num = call_req_id.ref_num; | |
| − | + | p_stat = call_req_id.status; | |
| − | + | p_statsym = call_req_id.status.sym; | |
| − | + | p_type = call_req_id.type.sym; | |
| − | + | wc = format("parent = '%s' AND status != '%s' AND status != 'RE' AND status != 'CL'", call_req_id, p_stat); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | send_wait(0, top_object(), "call_attr", "cr", "current_user_id"); | |
| − | + | login_userid = msg[0]; | |
| − | + | 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, 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","status.sym"); | |
| − | + | c_num = msg[3]; | |
| − | + | c_type = msg[6]; | |
| − | send_wait(0, top_object(), "get_co_group"); | + | c_origstatsym = msg[9]; |
| − | + | if (description == action_desc) { | |
| − | + | c_desc = "Status changed from \'" + c_origstatsym + "\' to \'" + p_statsym + "\'" ; | |
| − | + | } else { | |
| − | + | c_desc = description; | |
| − | + | } | |
| − | + | c_desc = c_desc + " (initiated from Parent " + p_type + " " + p_num + ")" ; | |
| − | + | send_wait(0, top_object(), "get_co_group"); | |
| − | + | group_leader = msg[0]; | |
| + | send_wait(0, c_dob, "change_status", group_leader, login_userid, c_desc, p_stat, NULL); | ||
| + | send_wait(0, group_leader, 'checkin'); | ||
| + | if (msg_error()) { | ||
| + | logf(ERROR, "error changing status to '%s' on Child %s %s from Parent %s %s - %s", p_statsym, c_type, c_num, p_type, p_num, msg[0]); | ||
| + | } else { | ||
| + | logf(SIGNIFICANT, "successfully set status to '%s' on Child %s %s from Parent %s %s", p_statsym, c_type, c_num, p_type, p_num); | ||
} | } | ||
} | } | ||
| − | |||
} | } | ||
}</source> | }</source> | ||
=== Step 2. Create the trigger === | === 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 '''[[ | + | 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 '''[[Act Log Table|alg (Request Activity Log)]]''' table. |
| − | <source lang="javascript">POST_VALIDATE | + | <source lang="javascript">POST_VALIDATE zstat_to_child() 111 FILTER((type{-> 'RE'} || type{-> 'ST'} || type{-> 'CL'}) && zset_child_f == 1);</source> |
| + | This trigger will activate when the Resolved (RE), Update Status (ST), or Closed (CL) Activities are initiated. | ||
=== Step 3. Add field to Object Engine === | === Step 3. Add field to Object Engine === | ||
| − | This step creates a field that exists only in the Object Engine which | + | 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 file|.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 { | <source lang="text">OBJECT alg { | ||
| Line 77: | Line 85: | ||
}; | }; | ||
};</source> | };</source> | ||
| + | ''Note: If the [[Propagate Solution to Children]] customization is implemented there is no need to add the zset_child_f field.'' | ||
=== Step 4. Edit the request_status_change.htmpl form === | === Step 4. Edit the request_status_change.htmpl form === | ||
| Line 85: | Line 94: | ||
</PDM_IF></source> | </PDM_IF></source> | ||
| − | Note: The <nowiki><PDM_IF></nowiki> prevents the checkbox from appearing if there are no children. Other conditions can be added the <nowiki><PDM_IF></nowiki> if this capability should have restricted use. | + | Note: The <nowiki><PDM_IF></nowiki> prevents the checkbox from appearing if there are no children. Other conditions can be added to the <nowiki><PDM_IF></nowiki> if this capability should have more restricted use. |
=== Step 5. Publish the Schema changes === | === Step 5. Publish the Schema changes === | ||
{{R11 Publish Schema Change}} | {{R11 Publish Schema Change}} | ||
| + | |||
| + | == See Also == | ||
| + | [[Propagate Solution to Children]]<br> | ||
| + | [[Set Request/Incident/Problem Status from Change Order]] | ||
Latest revision as of 16:19, 7 December 2008
To discuss or ask questions about this article, select the discussion tab above.
Overview
This article provides instructions for being able to set the Status of all child tickets when setting the Status of the parent.
This customization was designed for the r11.x releases, and is untested in older releases.
Benefits
- All Statuses can be passed from Parent to Children.
- The Child Activity Logs are annotated with syntax stating that the Status change was initiated by the Parent.
- The "Close All Children" option found in the Actions Menu is obsolete.
- Users have an option per Status update whether to propagate to the Children or not.
Known Issues
The Status of a Child cannot be updated if there are any requirements not yet fulfilled. For example, if RootCause is required on Resolve, then the Status will fail to update on the Children needing a RootCause, but will update all the other Children that have fulfilled their requirements. No alert is provided when Children fail to be update.
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::zstat_to_child(...) { string c_desc, c_num, c_origstatsym, c_type, p_num, p_stat, p_statsym, p_type, wc; object c_dob, c_list, group_leader; int c_count, i; uuid login_userid;
p_num = call_req_id.ref_num; p_stat = call_req_id.status; p_statsym = call_req_id.status.sym; p_type = call_req_id.type.sym; wc = format("parent = '%s' AND status != '%s' AND status != 'RE' AND status != 'CL'", call_req_id, p_stat);
send_wait(0, top_object(), "call_attr", "cr", "current_user_id"); login_userid = msg[0]; 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, 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","status.sym"); c_num = msg[3]; c_type = msg[6]; c_origstatsym = msg[9]; if (description == action_desc) { c_desc = "Status changed from \'" + c_origstatsym + "\' to \'" + p_statsym + "\'" ; } else { c_desc = description; } c_desc = c_desc + " (initiated from Parent " + p_type + " " + p_num + ")" ; send_wait(0, top_object(), "get_co_group"); group_leader = msg[0]; send_wait(0, c_dob, "change_status", group_leader, login_userid, c_desc, p_stat, NULL); send_wait(0, group_leader, 'checkin'); if (msg_error()) { logf(ERROR, "error changing status to '%s' on Child %s %s from Parent %s %s - %s", p_statsym, c_type, c_num, p_type, p_num, msg[0]); } else { logf(SIGNIFICANT, "successfully set status to '%s' on Child %s %s from Parent %s %s", p_statsym, c_type, c_num, p_type, p_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 zstat_to_child() 111 FILTER((type{-> 'RE'} || type{-> 'ST'} || type{-> 'CL'}) && zset_child_f == 1);</source> This trigger will activate when the Resolved (RE), Update Status (ST), or Closed (CL) Activities are 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 Solution to Children customization is implemented there is no need to add the zset_child_f field.
Step 4. Edit the request_status_change.htmpl form
This step will add a checkbox giving the option to propagate the Status to children. Add the following code:<source lang="javascript"><PDM_IF $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. 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
See Also
Propagate Solution to Children
Set Request/Incident/Problem Status from Change Order