Difference between revisions of "Set Priority Based on Urgency and Impact"
m (→Step 2. Create the trigger) |
m (→Step 2. Create the trigger) |
||
| Line 78: | Line 78: | ||
== Step 2. Create the trigger == | == Step 2. Create the trigger == | ||
| − | This step is to create the trigger that will initiate the script. | + | 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. |
| − | <source lang="javascript">POST_VALIDATE zmyscript() 111 FILTER(EVENT("INSERT") || (impact{} || urgency{}));</source> | + | |
| + | <font color="blue">For r11.x releases</font> triggers are created via the [[Schema Designer]] utility. Simply add the following code as a [[Site-Defined Trigger]] to the '''[[Call Req Table|cr (Request)]]''' table. | ||
| + | POST_VALIDATE zprefix() 111 FILTER(EVENT("INSERT") || (impact{} || urgency{})); | ||
| + | |||
| + | |||
| + | <font color="blue">For older releases</font> triggers are made 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'. | ||
| + | <source lang="javascript">OBJECT cr { | ||
| + | TRIGGERS { | ||
| + | POST_VALIDATE zmyscript() 111 FILTER(EVENT("INSERT") || (impact{} || urgency{})); | ||
| + | }; | ||
| + | };</source> | ||
== Step 3. Publish the Schema changes == | == Step 3. Publish the Schema changes == | ||
Revision as of 00:48, 8 July 2008
This article provides instructions for setting a ticket's priority field based on the values of it's urgency and impact fields. This customization works only in r11.x releases.
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(...){ int z_pri;
if ((urgency == 0) && (impact == 5))
{z_pri = 5; }
// priority = 4, is priority of High
if (((urgency == 0) && (impact == 4)) ||
((urgency == 0) && (impact == 3)) ||
((urgency == 1) && (impact == 5)) ||
((urgency == 1) && (impact == 4)) ||
((urgency == 2) && (impact == 5)))
{z_pri = 4;}
// priority =3, is priority of Medium
if (((urgency == 0) && (impact == 2)) ||
((urgency == 1) && (impact == 3)) ||
((urgency == 1) && (impact == 2)) ||
((urgency == 2) && (impact == 4)) ||
((urgency == 2) && (impact == 3)) ||
((urgency == 3) && (impact == 5)) ||
((urgency == 3) && (impact == 4)))
{z_pri = 3;}
// priority = 2, is priority of Low
if (((urgency == 2) && (impact == 2)) ||
((urgency == 3) && (impact == 3)) ||
((urgency == 3) && (impact == 2)))
{z_pri = 2;}
}
send_wait(0, this, "call_attr", "priority", "set_val", z_pri, "SURE_SET"); if (msg_error()) { logf(ERROR, "error setting priority to %s on %s %s - %s", z_pri, type.sym, ref_num, msg[0]); return; } else { logf(SIGNIFICANT, "successfully set priority to %s on %s %s", z_pri, type.sym, ref_num); } }</source> This script was based on the following matrix:
| 1-Critical | 2-High | 3-Medium | 4-Low | |
|---|---|---|---|---|
| 1-Critical | Critical | High | High | Medium |
| 2-High | High | High | Medium | Medium |
| 3-Medium | High | Medium | Medium | Low |
| 4-Low | Medium | Medium | Low | Low |
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 zprefix() 111 FILTER(EVENT("INSERT") || (impact{} || urgency{}));
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(EVENT("INSERT") || (impact{} || urgency{}));
};
};</source>
Step 3. Publish the Schema changes
Follow these steps for publishing the schema changes:
- Save your Schema changes
- Stop the Service Desk service
- Run pdm_publish from a command line
- Start the Service Desk service
To discuss or ask questions about this article, select the discussion tab above.