Prevent Close of Requests/Incidents/Problems if Change Order is Active

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 preventing the closing (or setting inactive) any Request, Incident, or Problem that has a currently open Change Order attached to it.

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">cr::zmyscript(...){ send_wait(0, this, "get_attr_vals", 2, "change.active", "change.chg_ref_num"); int co_act_val; string co_ref_num; co_act_val = msg[3]; co_ref_num = msg[6]; if(co_act_val == 1){ string zmsg; // Enter your alert message zmsg=format(" - Change %s must be resolved before closing this ticket.", co_ref_num); set_error(1); set_return_data(zmsg); return; } }</source>

Step 2. Create the trigger

This step is to create the trigger that will initiate the script. The methods used to implement the trigger vary based on the Service Desk release.

For r11.x releases triggers are created via the Schema Designer utility. Simply add the following code as a Site-Defined Trigger to the cr (Request) table.

POST_VALIDATE zmyscript() 111 FILTER((active{->0}) && (change!=NULL));

For older releases triggers are made 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'. <source lang="javascript">OBJECT cr {

 TRIGGERS {
   POST_VALIDATE zmyscript() 111 FILTER((active{->0}) && (change!=NULL));
 };

};</source>

Step 3. 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 release recycle the Service Desk service.