---
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


---

# GlideElementCurrency2 - Scoped

# GlideElementCurrency2 - Scoped {#ariaid-title1}

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

The GlideElementCurrency2 API provides methods to perform operations
on Foreign Exchange (FX) Currency fields (also known as Currency2) within the current
GlideRecord.  
This API provides methods that enable you to perform the following:

* Obtain the FX Currency field display string, as entered by the user.
* Obtain the display value of an FX Currency field.
* Obtain the reference currency value of an FX Currency field.
* Obtain the session currency value of an FX Currency field.
* Set the display value of an FX Currency field.
{#GlideElementCurrency2ScopedAPI__ul_dvb_b14_yjb}

The GlideElementCurrency2 class has no constructor.

## GlideElementCurrency2 - getAsEnteredDisplayValue() {#ariaid-title2}

Returns an FX Currency field display string, as entered by the user, from the associated
GlideRecord.
For additional information on FX Currency fields, see [Setting up and operating FX Currency
fields](https://www.servicenow.com/docs/access?context=fx-currency&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).
{#Scoped-GEC-getAsEntDispVal__table_tpv_5kd_fy__entry__3}

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

{#Scoped-GEC-getAsEntDispVal__table_tpv_5kd_fy} {#Scoped-GEC-getAsEntDispVal__table_upv_5kd_fy__entry__2}

| Type | Description |
|-|-|
| String | Display currency string as entered by the user. |
[Table 2. Returns]

{#Scoped-GEC-getAsEntDispVal__table_upv_5kd_fy}  
This example shows how to call the method.

    var tablename = 'my_currency2_table';
    var setcur2 = new GlideRecord(tablename);
    setcur2.initialize();
    setcur2.currency_2_field.setDisplayValue('JPY;999999.1234');
    setcur2.insert();
    gs.info('As entered display value: ' + setcur2.currency_2_field.getAsEnteredDisplayValue());

Output:

    As entered display value: ¥999,999.12

## GlideElementCurrency2 - getDisplayValue() {#ariaid-title3}

Returns the display value of an FX Currency field within the associated
GlideRecord.
Depending on how the display_value is set in the FX Currency Configuration \[fx_configuration\] table, the returned value may be the:

* Currency value as entered by the user
* Currency value converted to the session currency (based on the user's locale)
* Currency value converted to the reference currency
{#Scoped-GEC-getDisplayVal__ul_c3x_vhj_qjb}

For additional information on FX Currency and the configuration table, see [Configure FX Currency global
settings](https://www.servicenow.com/docs/access?context=fx-currency-configure&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).
{#Scoped-GEC-getDisplayVal__table_qxq_k5c_fy__entry__3}

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

{#Scoped-GEC-getDisplayVal__table_qxq_k5c_fy} {#Scoped-GEC-getDisplayVal__table_rxq_k5c_fy__entry__2}

| Type | Description |
|-|-|
| String | Display currency value |
[Table 4. Returns]

{#Scoped-GEC-getDisplayVal__table_rxq_k5c_fy}  
This example shows how to call the method.

    var tablename = 'my_FXcurrency_table';
    var setcur2 = new GlideRecord(tablename);
    setcur2.initialize();
    setcur2.currency_2_field.setDisplayValue('JPY;999999.1234');
    setcur2.insert();
    gs.info('Display Value: ' + setcur2.currency_2_field.getDisplayValue());

Output:

    Display Value: ¥999,999.12

## GlideElementCurrency2 - getReferenceDisplayValue() {#ariaid-title4}

Returns the reference currency value of an FX Currency field within the associated
GlideRecord.
Reference currency is the common currency into which all currency values in a field are converted. The currency code that the getReferenceDisplayValue() method uses to derive the reference currency is based on the following:

* If an instance record exists, then the method uses the value in the reference_currency field of the FX Currency \[fx_currency2_instance\] table.
* If an instance record does not exist, then the method uses the reference currency that would be set on the instance record when the instance record is eventually created (in the following order):
  * If set, the reference_currency in the FX Currency Configuration \[fx_configuration\] table.
  * If set, the reference_currency_source in the FX Currency Configuration \[fx_configuration\] table.
  * System default, system reference currency.
  {#Scoped-GEC-getRefDispVal__ul_sb1_2tx_sjb}
{#Scoped-GEC-getRefDispVal__ul_l5z_x3j_qjb}

For additional information on the values in the FX Currency Configuration
\[fx_configuration\] table, see [Setting up and operating FX Currency
fields](https://www.servicenow.com/docs/access?context=fx-currency&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).
{#Scoped-GEC-getRefDispVal__table_ywn_hmd_fy__entry__3}

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

{#Scoped-GEC-getRefDispVal__table_ywn_hmd_fy} {#Scoped-GEC-getRefDispVal__table_zwn_hmd_fy__entry__2}

| Type | Description |
|-|-|
| String | Reference currency amount for the associated FX Currency display value. |
[Table 6. Returns]

{#Scoped-GEC-getRefDispVal__table_zwn_hmd_fy}  
This example assumes the reference currency code is USD and uses the default conversion
rate specified in the FX Currency Configuration \[fx_configuration\] table. The output will
change based on locale.

    var tablename = 'my_currency2_table';
    var setcur2 = new GlideRecord(tablename);
    setcur2.initialize();
    setcur2.currency_2_field.setDisplayValue('JPY;999999.1234');
    setcur2.insert();
    gs.info('Reference display value: ' + setcur2.currency_2_field.getReferenceDisplayValue());

Output:

    Reference display value: $8,677.99

## GlideElementCurrency2 - getSessionDisplayValue() {#ariaid-title5}

Returns the session currency value of the associated FX Currency field within the
current GlideRecord.
{#Scoped-GEC-getSesDispVal__table_ozy_rld_fy__entry__3}

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

{#Scoped-GEC-getSesDispVal__table_ozy_rld_fy} {#Scoped-GEC-getSesDispVal__table_pzy_rld_fy__entry__2}

| Type | Description |
|-|-|
| String | Currency value converted to the session currency, which is based on the current user's locale. |
[Table 8. Returns]

{#Scoped-GEC-getSesDispVal__table_pzy_rld_fy}  
This example assumes the session locale is language code = eng and country code = USA, and
uses the default conversion rate specified in the FX Currency Configuration
\[fx_configuration\] table. The output will change based on locale.

    var tablename = 'my_currency2_table';
    var setcur2 = new GlideRecord(tablename);
    setcur2.initialize();
    setcur2.currency_2_field.setDisplayValue('JPY;999999.1234');
    setcur2.insert();
    gs.info('Session display value: ' + setcur2.currency_2_field.getSessionDisplayValue());

Output:

    Session display value: $8,677.99

## GlideElementCurrency2 - setDisplayValue(String displayValue) {#ariaid-title6}

Sets the display value of an FX Currency field with the specified currency
value.
For additional information on FX Currency fields, see [Setting up and operating FX Currency
fields](https://www.servicenow.com/docs/access?context=fx-currency&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).
{#Scoped-GEC-setDisplayVal_S__table_enw_5jd_fy__entry__3}

| Name | Type | Description |
|-|-|-|
| displayValue | String | Value to set in the FX Currency field in the format `<currency code>;<currency amount>`. You must format the `<currency amount>` field in the user's locale. For example, if the user's locale is USA/eng, the passed in `<currency amount>` would be 123.45. If the user's local is FRA/fre, the passed in `<currency amount>` would be 123,45. |
[Table 9. Parameters]

{#Scoped-GEC-setDisplayVal_S__table_enw_5jd_fy} {#Scoped-GEC-setDisplayVal_S__table_fnw_5jd_fy__entry__2}

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

{#Scoped-GEC-setDisplayVal_S__table_fnw_5jd_fy}  
This example shows how to call the method.

    var tablename = 'my_FXcurrency_table';
    var setcur2 = new GlideRecord(tablename);
    setcur2.initialize();
    setcur2.currency_2_field.setDisplayValue('JPY;999,999.1234');
    setcur2.insert();


