Is it possible to use GlideAggregate for SUM with a Currency type field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 08:48 AM
I cannot figure out the proper way to make a sum of the currency field found in the GlideAggregate query.
As per the below script, whether using a while loop or an if, it seems to go by each record one by one, returning the current record's field value, rather than summing it up.
What I'm trying to achieve is to calculate a sum of attached records' "total cost" Currency field.
What's the use of GlideAggregate if it wouldn't be meant for use with this type? I can see that the official docs suggest it's possible:
https://docs.servicenow.com/bundle/newyork-platform-administration/page/administer/currency/concept/currency-values-scripts.html
i.e.: "When you use GlideAggregate on currency or price fields, you are working with the reference currency value. "
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2020 09:56 AM
Hi,
Here is link which has example of GlideAggregate which will help you.
If it Helps,please mark it as Correct and Helpful.
Warm Regards,
Milind
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 01:35 AM
setGroup(Boolean b)
In your code add this line
workOrders.setGroup(false);
If it helps,please mark it as Correct and Helpful.
Thanks,
Jatin