Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

get DisplyValue from Glideaggregate

Holger Peters
Tera Contributor

Heho,

 

is there any chance to get the displayValue from GlideAggregate as I can get if from GlideRecord.

The thing is, that I want this number formatted. So for a German user I need: "2235,2300000"

 

example code:

var agg = new GlideAggregate('order_price');
agg.addEncodedQuery("some query");
agg.addAggregate('SUM', 'price');
agg.groupBy('price_type');
agg.query();
while (agg.next()) {

var sum = agg.getAggregate('SUM', 'price');
gs.info(JSON.stringify(sum,"",2));
}

 

Output: 

"2235.2300000"

 

7 REPLIES 7

Theo BOULANGER
Giga Guru

Hello @Holger Peters 

 

You can replace the comma with a dot if you need to:

 

parseFloat(sum.replace(/[,]+/g,".");

 

Regards,

Theo

all these these later adjustments have the problem, that I need to figure out, what the current system language is... Like getDisplayValue from glideRecord already knows and does... No chance to get something like this from GlideAggregate???

I think the problem is that the browser Language dictates the decimal separator to use..

You can also use a field format to get this final results 🙂

Aman Kumar S
Kilo Patron

Hi @Holger Peters ,

You can below article to re-format your output:

https://www.servicenow.com/community/developer-forum/decimal-price-field-sometimes-comma-sometimes-d...

Best Regards
Aman Kumar