Default currency values in scripts
-
- UpdatedAug 3, 2023
- 4 minutes to read
- Vancouver
- Currency fields
You can use currency fields in scripts.
These methods are available on GlideElement objects.
To display currency values, use the getDisplayValue() display API. To work with currency values in any way other than display, use the APIs that return/accept unformatted numbers.
You are working with the reference currency value when you use GlideAggregate on currency or price fields. Be sure to convert the aggregate values to the user's session currency for display. The resulting value may not be what you expect. The conversion rate used for the currency or price field value, and for its reference currency, which is used for the aggregation, may have changed.
- APIs that return values such as getValue() return up to four decimal places. Trailing zeros are always removed.
- APIs that return display values such as getDisplayValue() have at least two decimal places and up to four decimal places.
- GlideAggregate returns four decimal places.
- APIs that return values such as getValue() return up to two decimal places. The trailing zeroes are removed for values read from the database, but if a value such as 00 is set later, 1.00 can be returned. The number of trailing zeros returned is not consistent.
- APIs that return display values such as getDisplayValue() contain up to two decimal places. It could sometimes return two places even for values such as 7.10, but could remove trailing zeros at other times. The number of trailing zeros returned is not consistent.
- GlideAggregate returns two decimal places.