getEventCategories Function
The getEventCategories
function allows retrieving all the categories configured in the current event schema, and ranked in order of importance, with the most important on top. It is also possible to get one or multiple specific categories depending on their <positions>
in the array of the configured categories. The position values start at 1.
Syntax
var result = getEventCategories(<positions>);
Parameters Usage
Parameter | Type | Default | Use | Annotation |
positions | Integer Integer Array | null | Optional | Positions of the required categories. The most important category is on top (position = 1), the less important is the last (count of the array of all the categories). The default value means all the configured categories. |
Result
The getEventCategories
function returns an EventCategories object.
Error Handling
Errors can occur in case:
- The specified position is out of range or is not a positive integer.
Examples of Use
How to get and print to Console all the categories configured in an event schema
var categories = getEventCategories();
console(categories)
How to get the most important category and print it to Console
var categories = getEventCategories(1);
console(categories[0])
The above instructions print to the Console expander:
id = 15
descriptor = Emergency
How to get the two less important categories and print them to Console
var categoriesCount = getEventCategories().length;
var categories = getEventCategories([categoriesCount, categoriesCount - 1]);
console(categories[0])
console(categories[1])
Or
var allCategoriesReverseOrder = getEventCategories().toArray().reverse();
console(allCategoriesReverseOrder[0])
console(allCategoriesReverseOrder[1])