Counting notes added to an incident

This example describes how to add a field to the Incident window that reports the number of notes added to the incident. You can use a similar calculation to count the number of items in any collection on any object. You could use a calculation like this in a process condition that changes the process flow if a certain number of assignments or child incidents are added to an incident.

To count the number of notes added to an incident:
  1. In Object Designer, create a string attribute on the Incident Management\Incident object called Count Notes.
  2. In the Properties grid, set the Calculation Type to BeforeSave.
    The Edit Formula dialog appears.
  3. Click in the Editor box at the end of the line Value =
  4. In the Attributes tree, double-click Notes[].
    The line changes to Value = Incident.Notes.
  5. In the Function tree, double-click Count from the Framework Collection Functions branch.
    The calculation reads:
import System
static def GetAttributeValue(Incident):
	Value = Incident.Notes.Count
	return Value
  1. Click Test Syntax to confirm that the calculation contains no errors in its structure, then click OK.
    The Calculation is added to the attribute.
  2. Save the changes to the object, then start Window Manager.
  3. Open the Incident window, and add the attribute Count Notes.
    When you save the window, this field will report the number of notes added to the incident.

Because the Count function returns the required value, you can use the function directly in the return line if you prefer:

import System
static def GetAttributeValue(Incident):
	return Incident.Notes.Count


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other