Close Ticket automatically after a delay
Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.
Let's assume we want to automatically close Ticket which are in
frozen
state for more than 21 days
What do we need to do for this:
-
Add a Stopwatch with threshold(s) and goal
-
Write the Computing method
-
Define Trigger and Notifications on your iTop instance, if you want to notify the customer before automatically closing the ticket
Add Stopwatch
-
Add a Stopwatch field on the UserRequest class
-
Define the states during which the Stopwatch will be running
-
Considering that the Delay of 21 days does not need to care about neither business hours nor week-ends & vacations, we use 24*7 coverage window, which is the default. Its code is
DefaultWorkingTimeComputer
. -
Define threshold(s), here I defined three so I can use them later in trigger and notifications.
-
On 100% Threshold, which is when the goal is reached, I force the UserRequest to close it-self, which will stop the stopwatch as the UserRequest will no more be in a state where the stopwatch is running.
-
Set a goal
Put this in a datamodel.my-extension.xml file of your extension
- classes / class@UserRequest / fields
-
<field id="pending_customer_stopwatch" xsi:type="AttributeStopWatch" _delta="define"> <states> <state id="frozen">frozen</state> </states> <working_time>DefaultWorkingTimeComputer</working_time> <thresholds> <threshold id="33"> <actions/> </threshold> <threshold id="66"> <actions/> </threshold> <threshold id="100"> <actions> <action> <verb>ApplyStimulus</verb> <params> <param xsi:type="string">ev_resolve</param> </params> </action> </actions> </threshold> </thresholds> <always_load_in_tables>true</always_load_in_tables> <goal>ComputePendingDelay</goal> </field>
Computing method
Put this in a main.my-extension.php of your extension
class ComputePendingDelay implements iMetricComputer { public static function GetDescription() { return "Used to compute delay when pending caller"; } public function ComputeMetric($oObject) { // Set the delay as a configuration parameter if you wish or hardcode it. $iDelay = MetaModel::GetModuleSetting('itop-request-mgmt', 'pending_delay', '21'); $iRes = $iDelay*86400; // $iDelay in days * 86400 seconds within one day return $iRes; } }
Define Notifications
🚧 to be added
2_7_0/customization/auto-close.txt
· Last modified: 2020/06/11 16:57 by 127.0.0.1