GlideElementCurrency2 - Scoped
-
- UpdatedJan 30, 2025
- 3 minutes to read
- Yokohama
- API reference
The GlideElementCurrency2 API provides methods to perform operations on Foreign Exchange (FX) Currency fields (also known as Currency2) within the current GlideRecord.
- 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.
The GlideElementCurrency2 class has no constructor.
GlideElementCurrency2 - getAsEnteredDisplayValue()
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.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Display currency string as entered by the user. |
Example
This example shows how to call the method.
Output:
GlideElementCurrency2 - getDisplayValue()
Returns the display value of an FX Currency field within the associated GlideRecord.
- 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
For additional information on FX Currency and the configuration table, see Configure FX Currency global settings.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Display currency value |
Example
This example shows how to call the method.
Output:
GlideElementCurrency2 - getReferenceDisplayValue()
Returns the reference currency value of an FX Currency field within the associated GlideRecord.
- 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.
For additional information on the values in the FX Currency Configuration [fx_configuration] table, see Setting up and operating FX Currency fields.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Reference currency amount for the associated FX Currency display value. |
Example
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.
Output:
GlideElementCurrency2 - getSessionDisplayValue()
Returns the session currency value of the associated FX Currency field within the current GlideRecord.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Currency value converted to the session currency, which is based on the current user's locale. |
Example
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.
Output:
GlideElementCurrency2 - setDisplayValue(String displayValue)
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.
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 |
Type | Description |
---|---|
void |
Example
This example shows how to call the method.