Calculation functions

The following functions are available in the calculation editor:

Framework Object Functions

GetBusinessTime( DateTime1 , DateTime2 ) – returns the number of business hours between two date/time values based on the calendar associated with the response level for the process.
For example, TimeSinceResolved = Incident.GetBusinessTime(Resolution.CreationDate, DateTime.UtcNow) sets TimeSinceResolved to equal the difference in business hours between the creation date of the latest resolution (Resolution.CreationDate), and the current time in UTC (the DateTime function DateTime.UtcNow) based on the calendar used by the Incident’s response level.

GetNamedObject("DataObject", value) – returns the value of an object, where DataObject is the fully qualified object name, and value is the value of the Is Name? attribute.
For example, return Incident.GetNamedObject("IncidentManagement._Example", "123") returns the Example object in the Incident Management module called 123.

GetObjectByAttribute("DataObject", "attribute", value) – returns the value of an object, where DataObject is the fully qualified object name, and value is the value of the selected attribute.
For example, return Incident.GetObjectByAttribute("System.User", "Phone", "1234") returns the User whose Phone is 1234.

For both GetNamedObject() and GetObjectByAttribute(), the function returns the first object that matches the value specified. We recommend that you use these functions only where the value you specify is unique.

GetRankedObject("DataObject",rank ) – returns the value of a ranked object, where DataObject is the fully qualified object name, and rank is the number in the ranked sequence.
For example, return Incident.GetRankedObject("IncidentManagement._MyPriority", 2 ) returns the second value in the MyPriority ordered list in the Incident Management module.

GetReferencedObject("MatchingObject") – returns the object of an object reference, where MatchingObject is the object reference. It.is particularly useful when used with the Search Matches collection generated by the Automatic Search behaviour. For more information about this and an example of its usage, see the Knowledge Management Guide.

MinutesToBreach() – returns the number of minutes until the object breaches as an integer value, taking into account working hours.
For example, return Incident.MinutesToBreach() returns the number of minutes until the incident breaches.

TimeToBreach() – returns the time until the object breaches as a string value in the form hhhh:mm:ss, taking into account working hours. Note that because this returns a string, you will not be able to sort on this value.
For example, return Incident.TimeToBreach() returns the time until the incident breaches.

Framework Collection Functions

First() – returns the value of the specified attribute with the earliest Creation Date.
For example, item = Incident.Assignments.First() selects first of the assignments created for the incident; you could then use return item.Title to return the title of the first assignment.

Latest() – returns the value of the specified attribute with the latest Creation Date.
For example, item = Incident.Assignments.Latest() selects latest of the assignments created for the incident.

Max("attribute") – returns the maximum value of the specified attribute.
For example, Value = Incident.Assignments.Max("_Duration") sets Value to be equal to the largest value of the attribute called _Duration on any of the assignments for the incident.

Min("attribute") – returns the minimum value of the specified attribute.
For example, Value = Incident.Assignments.Min("_Duration") sets Value to be equal to the smallest value of the attribute called _Duration on any of the assignments for the incident.

Count – returns the number of items in the specified collection.
For example, return Incident.Assignments.Count returns the number of assignments for the incident.

DateTime Functions

DateTime.Now – returns the current local date and time in date/time format. You can return just the value of the current Second, Minute, Hour, Day, Month, or Year using the relevant sub-option.

DateTime.Today – returns today's date in date/time format; the time fields will return midnight.

DateTime.UtcNow – returns the current UTC date and time in date/time format. You can return just the value of the current Second, Minute, Hour, Day, Month, or Year using the relevant sub-option.

Runtime Functions

GetCurrentGroupName() – returns the Name of the Current Group of the logged in User.

GetCurrentUserName() – returns the Name of the logged in User.