---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideCurrencyParser - Scoped

# GlideCurrencyParser - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The GlideCurrencyParser API provides methods to parse FX Currency
values to detect locale-based formatting.

The methods in this class parse a specified string into a [GlideCurrencyValue](https://servicenow-prod.fluidtopics.net/S7NHx_c3coXzLu4e~zVJxg#GlideCurrencyValueScopedAPI "The GlideCurrencyValue API provides methods that return the currency code and original currency from an associated GlideCurrencyParser.parse() call.") object enabling you to obtain locale-based currency formatting.
Before calling the GlideCurrencyParser.parse() method, which actually
performs the parse, you must set the currency code to use during the parse. You can set the
currency code by either passing it in the GlideCurrencyParser.parse()
method call or by calling GlideCurrencyParser.setDefaultCurrencyCode().

Setting the locale is optional. If you do not set it through the
GlideCurrencyParser.setLocale() method, the currency amount passed into
GlideCurrencyParser.parse() must be unformatted.

This class runs is in the `sn_currency` namespace.

## GlideCurrencyParser - GlideCurrencyParser() {#ariaid-title2}

Instantiates a GlideCurrencyParser object that provides methods to parse a string into
a GlideCurrencyValue object.
{#GCPS-GlideCurrencyParser__table_s5m_rh2_4jb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#GCPS-GlideCurrencyParser__table_s5m_rh2_4jb}  
This example shows how to call the method.

    var parser = new sn_currency.GlideCurrencyParser();

## GlideCurrencyParser - parse(String value) {#ariaid-title3}

Parses a specified string into a GlideCurrencyValue object to obtain locale-based
currency formatting.
{#GCPS-parse_S__table_wpy_532_4jb__entry__3}

| Name | Type | Description |
|-|-|-|
| value | String | String to parse. You can prepend this string with the ISO currency code to use when parsing the string (semicolon separated). If the currency code is not set prior to calling the parse() method, it defaults to the current session currency code. This method supports both decimal point and decimal comma notation. For example: "123.45", "USD;123.45", "123,45", "EUR;123,45" |
[Table 2. Parameters]

{#GCPS-parse_S__table_wpy_532_4jb} {#GCPS-parse_S__table_xpy_532_4jb__entry__2}

| Type | Description |
|-|-|
| GlideCurrencyValue | Parsed value information. Data type: Object |
[Table 3. Returns]

{#GCPS-parse_S__table_xpy_532_4jb}  
This example sets the locale to France and then parses the passed currency value to US
dollars.

    var gp = new sn_currency.GlideCurrencyParser();
    gp.setLocale("fr", "FR");
    var cv = gp.parse("USD;1234,56");
    gs.info(cv);

Output:

    USD;1234.56

This example sets the default currency code to US dollars and then parses the currency
value.

    var amount = "1234.56"
    var gp = new sn_currency.GlideCurrencyParser();
    gp.setDefaultCurrencyCode("USD");
    var cv = gp.parse(amount);
    gs.info(cv);

Output:

    USD;1234.56

## GlideCurrencyParser - setDefaultCurrencyCode(String currencyCode) {#ariaid-title4}

Sets the currency code for the associated GlideCurrencyParser object.
{#GCPS-setDefaultCurrencyCode_S__table_tww_5zz_4jb__entry__3}

| Name | Type | Description |
|-|-|-|
| currencyCode | String | Three-letter ISO currency code to use as the default in the associated GlideCurrencyParser object. |
[Table 4. Parameters]

{#GCPS-setDefaultCurrencyCode_S__table_tww_5zz_4jb} {#GCPS-setDefaultCurrencyCode_S__table_uww_5zz_4jb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 5. Returns]

{#GCPS-setDefaultCurrencyCode_S__table_uww_5zz_4jb}  
The following example sets the default currency code to US dollars.

    var amount = "123.45"
    var gp = new sn_currency.GlideCurrencyParser();
    gp.setDefaultCurrencyCode("USD");
    var cv = gp.parse(amount);
    gs.info(cv);

Output:

    USD;123.45

## GlideCurrencyParser - setLocale(String language, String country) {#ariaid-title5}

Sets the default language and country codes, which constitute the locale, on the
associated GlideCurrencyParser object.
If you do not call this method before calling the
GlideCurrencyParser.parse() method, the locale defaults to the current
session locale.
{#GCPS-setLocale_S_S__table_e1j_shz_4jb__entry__3}

| Name | Type | Description |
|-|-|-|
| language | String | Two-letter ISO 639 language code, such as en, es, and fr. |
| country | String | Two-letter ISO 3166 country code, such as US, ES, and FR. |
[Table 6. Parameters]

{#GCPS-setLocale_S_S__table_e1j_shz_4jb} {#GCPS-setLocale_S_S__table_f1j_shz_4jb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 7. Returns]

{#GCPS-setLocale_S_S__table_f1j_shz_4jb}  
The following example shows how to set the locale to Spain.

    var amount = "USD;1.234,56"
    var gp = new sn_currency.GlideCurrencyParser();
    gp.setLocale("es", "ES");
    var cv = gp.parse(amount);
    gs.info(cv);

Output:

    USD;1234.56


