Sidebar

Using iTop

Creating your iTop

iTop Customization

"How to" examples
DataModel

User Interface

Automation & Ticket management

Portal Customization

:: Version 3.2.0 ::

Notify after a delay spent in a state

Prerequisite: You must be familiar with the Syntax used in Tutorials

learning:
Count time spent by Ticket within particular state(s) and notify above a limit
level:
Advanced
domains:
XML, Stopwatch, Automation, Lifecycle
methods:
ComputeMetric, iMetricComputer
min version:
2.3.0

Tutorial goal

In this tutorial, we want to notify someone, when a ticket spends more than 2h in a assigned state, and again when we have reached 6h in that state. This requires to:

  1. Define a PHP class implementing iMetricComputer, in order to compute that fixed delay as the future stopwatch goal.
  2. Add a stopwatch attribute on UserRequest class, to count when the ticket is in “assigned” state, with a fixed goal, defined in a configuration parameter.
  3. Set the working_time to DefaultWorkingTimeComputer to count time 24*7 or set it to SLAComputation for taking the working periods into account (usually applicable on a sub-ticket class only).

with the Designer

Prerequisite: You must be a Combodo's customer

Define a goal

This action requires to have the profile “Designer PHP developer”, if you have not, raise a support ticket to Combodo, to get it created for you.

We defined a 6h delay and notify after 2h hours and again after 6h

Pay attention to the selected module, choose itop-tickets
class FixedDelayMetric implements iMetricComputer
{
    public static function GetDescription()
    {
            return "iTop configurable delay in hours, 6 by default";
    }
    public function ComputeMetric($oObject)
    {
        // goal is expected to be provided in seconds
 
        // We can request a delay in hours from a module parameter, defined in the iTop Configuration file
 
        $iRes = 3600 * MetaModel::GetConfig()->GetModuleSetting('itop-tickets', 'pending_delay', '6');
        return $iRes;
    }
}

Then add the delay in your iTop Configuration file

Configuration file
$MyModuleSettings = array(
    'itop-tickets' => array(
        'pending_delay' => 36,
    ),

Add a Stopwatch

To create a stopwatch, click on the small Add button next to the title “Stopwatches” in the bottom pane.

Selection of a stopwatch

Give it a code, a label and select the state(s) in which the stopwatches should be running, here just assigned

Add a Threshold at 33% of the goal

And another Threshold at 100% of the goal

Define Working time

On iTop Products, when no working time is defined on a threshold, then automatically the SLAComputation is used with this oql:

Configuration
        'combodo-sla-computation' => array (
                'coverage_oql' => 'SELECT CoverageWindow AS cw 
                       JOIN lnkCustomerContractToService AS l1 ON l1.coveragewindow_id = cw.id 
                       JOIN CustomerContract AS cc ON l1.customercontract_id = cc.id 
                       WHERE cc.org_id= :this->org_id AND l1.service_id = :this->service_id',
                'holidays_oql' => 'SELECT Holiday',
        ), 

So if the object on which you have created the stopwatch, has no service_id or no org_id, then the above query cannot be used and you will need a different working time.

If the above query is not applicable on your stopwatch, request Combodo to inject in XML, the appropriate Working time:
<working_time>DefaultWorkingTimeComputer</working_time>
  • For 24*7, uses DefaultWorkingTimeComputer
  • For your own method to compute working time, you need to create a new class implementing the iWorkingTimeComputer interface and use it as working_time of your stopwatch.

with an iTop Extension

Prerequisite: You must have already created an iTop extension.

Create an iTop extension

Define a goal

In a php file:

class FixedDelayMetric implements iMetricComputer
{
    public static function GetDescription()
    {
            return "Fixed 6h delay";
    }
    public function ComputeMetric($oObject)
    {
        $iRes = 6*3600; // goal is expected to be provided in seconds
        return $iRes;
    }
}

Add a stopwatch

In the xml file:

itop_design / classes / class@UserRequest / fields
      <!-- Add a stopwatch to count the timespent in this state -->
      <field id="fixdelay" xsi:type="AttributeStopWatch" _delta="define">
        <states>
          <!-- here are the states during which the stopwatch is counting time -->
          <state id="assigned">assigned</state>
        </states>
        <!-- here we decided to count time regardless of the working hours -->
        <working_time>DefaultWorkingTimeComputer</working_time>
        <thresholds/>
        <goal>FixedDelayMetric</goal>
        <always_load_in_tables>true</always_load_in_tables>
      </field>
itop_design / dictionaries / dictionary@EN US / entries
  <entry id="Class:UserRequest/Attribute:fixdelay" _delta="define">
    <![CDATA[6h Delay]]>
  </entry>

Configure Notifications

In your iTop you must now define Triggers based on thresholds and linked then to a Notification action.

Of course you will use your newly created stopwatch fixdelay and the available thresholds are 33 and 100.

3_2_0/customization/add-stopwatch.txt · Last modified: 2024/09/10 10:25 (external edit)
Back to top
Contact us