what is the glide aggregate function?how to use

preddy1
Giga Expert

what is the glide aggregate function?how to use

1 ACCEPTED SOLUTION

Hi 

Please try it in the background script :-

 

var count =new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents =0;
if(count.next())

{

incidents = count.getAggregate('COUNT');
gs.print(incidents);
}

Copy paste this code in Background script.

See below :-

 

find_real_file.png

 

find_real_file.png

find_real_file.png

Regards,

 

Omkar Mone.

www.dxsherpa.com

View solution in original post

23 REPLIES 23

after wrighting the business rule where should we see the result log

Hi 

You can check it in debug business rule module :-

find_real_file.png

Tejal Zete
Giga Expert

Hi,

 

I hope following links will help you:

 

https://docs.servicenow.com/bundle/jakarta-application-development/page/script/glide-server-apis/concept/c_GlideAggregate.html

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/glide_server_apis/reference/r_GlideAggregateExamples.html

 

Mark it helpful/correct if it helps.

 

Thanks,

Tejal

where should i wright these scripts?and the entire script i need to wright that you have given?

Hi,

GlideAggregate enables you to easily create database aggregation queries.

The scoped GlideAggregate class is an extension of GlideRecord and provides database aggregation (COUNT, SUM, MIN, MAX, AVG) queries. This functionality can be helpful when creating customized reports or in calculations for calculated fields. The GlideAggregateclass works only on number fields.

When you use GlideAggregate on currency or price fields, you are working with the reference currency value. Be sure to convert the aggregate values to the user's session currency for display. Because the conversion rate between the currency or price value (displayed value) and its reference currency value (aggregation value) might change, the result may not be what the user expects.

You can write this scripts in Business rule and its up to you what result you want which functions need for it.

 

Mark my answer as correct if it helps and close the thread so other can refer it.

 

Thanks ,

Tejal