Difference between revisions of "Set Priority Based on Urgency and Impact"
(New page: __NOTOC__ 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....) |
m |
||
| Line 7: | Line 7: | ||
<source lang="javascript">cr::zmyscript(...){ | <source lang="javascript">cr::zmyscript(...){ | ||
| − | + | int z_priority; | |
| − | + | if( (urgency.value == 1) && (impact.value == 1)){ | |
| − | + | z_priority = 5; | |
| − | + | } else if( (urgency.value == 1) && (impact.value == 2)){ | |
| − | + | z_priority = 5; | |
| − | + | } else if( (urgency.value == 1) && (impact.value == 3)){ | |
| − | + | z_priority = 5; | |
| − | + | } else if( (urgency.value == 1) && (impact.value == 4)){ | |
| − | + | z_priority = 5; | |
| − | + | } else if( (urgency.value == 2) && (impact.value == 1)){ | |
| − | + | z_priority = 5; | |
| + | } else if( (urgency.value == 2) && (impact.value == 2)){ | ||
| + | z_priority = 4; | ||
| + | } else if( (urgency.value == 2) && (impact.value == 3)){ | ||
| + | z_priority = 4; | ||
| + | } else if( (urgency.value == 2) && (impact.value == 4)){ | ||
| + | z_priority = 3; | ||
| + | } else if( (urgency.value == 3) && (impact.value == 1)){ | ||
| + | z_priority = 5; | ||
| + | } else if( (urgency.value == 3) && (impact.value == 2)){ | ||
| + | z_priority = 4; | ||
| + | } else if( (urgency.value == 3) && (impact.value == 3)){ | ||
| + | z_priority = 3; | ||
| + | } else if( (urgency.value == 3) && (impact.value == 4)){ | ||
| + | z_priority = 3; | ||
| + | } else if( (urgency.value == 4) && (impact.value == 1)){ | ||
| + | z_priority = 5; | ||
| + | } else if( (urgency.value == 4) && (impact.value == 2)){ | ||
| + | z_priority = 3; | ||
| + | } else if( (urgency.value == 4) && (impact.value == 3)){ | ||
| + | z_priority = 3; | ||
| + | } else if( (urgency.value == 4) && (impact.value == 4)){ | ||
| + | z_priority = 2; | ||
| + | } else { | ||
| + | z_priority = 1; | ||
| + | } | ||
| + | send_wait(0, this, "call_attr", "priority", "set_val", z_priority, "SURE_SET"); | ||
| + | if (msg_error()) { | ||
| + | logf(ERROR, "error setting priority to %s on %s %s - %s", z_priority, type.sym, ref_num, msg[0]); | ||
| + | return; | ||
| + | } else { | ||
| + | logf(SIGNIFICANT, "successfully set priority to %s on %s %s", z_priority, type.sym, ref_num); | ||
| + | } | ||
| + | |||
}</source> | }</source> | ||
Revision as of 15:37, 7 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_priority; if( (urgency.value == 1) && (impact.value == 1)){ z_priority = 5; } else if( (urgency.value == 1) && (impact.value == 2)){ z_priority = 5; } else if( (urgency.value == 1) && (impact.value == 3)){ z_priority = 5; } else if( (urgency.value == 1) && (impact.value == 4)){ z_priority = 5; } else if( (urgency.value == 2) && (impact.value == 1)){ z_priority = 5; } else if( (urgency.value == 2) && (impact.value == 2)){ z_priority = 4; } else if( (urgency.value == 2) && (impact.value == 3)){ z_priority = 4; } else if( (urgency.value == 2) && (impact.value == 4)){ z_priority = 3; } else if( (urgency.value == 3) && (impact.value == 1)){ z_priority = 5; } else if( (urgency.value == 3) && (impact.value == 2)){ z_priority = 4; } else if( (urgency.value == 3) && (impact.value == 3)){ z_priority = 3; } else if( (urgency.value == 3) && (impact.value == 4)){ z_priority = 3; } else if( (urgency.value == 4) && (impact.value == 1)){ z_priority = 5; } else if( (urgency.value == 4) && (impact.value == 2)){ z_priority = 3; } else if( (urgency.value == 4) && (impact.value == 3)){ z_priority = 3; } else if( (urgency.value == 4) && (impact.value == 4)){ z_priority = 2; } else { z_priority = 1; } send_wait(0, this, "call_attr", "priority", "set_val", z_priority, "SURE_SET"); if (msg_error()) { logf(ERROR, "error setting priority to %s on %s %s - %s", z_priority, type.sym, ref_num, msg[0]); return; } else { logf(SIGNIFICANT, "successfully set priority to %s on %s %s", z_priority, type.sym, ref_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 cr (Request) table. <source lang="javascript">POST_VALIDATE zmyscript() 111 FILTER(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.