- Mastering ServiceNow Scripting
- Andrew Kindred
- 145字
- 2021-06-24 19:08:39
GlideAggregate
The GlideAggregate class is an extension of GlideRecord and works in a similar way. The difference is that GlideRecord tends to give you database objects whereas GlideAggregate deals in counts and numbers.
We'll take a quick look at how GlideAggregate works:
var counter = new GlideAggregate('incident');
counter.addAggregate('COUNT');
counter.query();
if (counter.next()) {
var noOfIncidents = counter.getAggregate('COUNT');
}
This first example will give us the number of incidents in the database and place it in the noOfIncidents field. We can add addQuery lines in exactly the same way we would for GlideRecord if we wanted to reduce the number of incident records we returned.
As well as COUNT, we can also use SUM, MAX, MIN, and AVG to get the total sum, maximum number, minimum number, and average, respectively.
I don't find GlideAggregate used that regularly, but it is an efficient way to count records.
推薦閱讀
- Google Cloud Platform Cookbook
- 21天學通PHP
- Natural Language Processing Fundamentals
- 基于多目標決策的數據挖掘方法評估與應用
- Prometheus監控實戰
- Implementing AWS:Design,Build,and Manage your Infrastructure
- 筆記本電腦維修90個精選實例
- 教育機器人的風口:全球發展現狀及趨勢
- 網絡服務搭建、配置與管理大全(Linux版)
- Salesforce Advanced Administrator Certification Guide
- Apache源代碼全景分析(第1卷):體系結構與核心模塊
- WOW!Photoshop CS6完全自學寶典
- 計算機應用基礎實訓(職業模塊)
- 漢字錄入技能訓練
- 巧學活用Photoshop