GlideCurrencyExchangeValue - Scoped

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 1 minute to read
  • Provides access to information related to FX Currency conversions.

    Refer to the GlideCurrencyConverter() API for methods that return a GlideCurrencyExchangeValue object.

    This class runs is in the sn_currency namespace.

    Note:
    There is no constructor for this class.

    Scoped GlideCurrencyExchangeValue - getAmount()

    Returns the currency amount after the conversion.

    Table 1. Parameters
    Name Type Description
    None
    Table 2. Returns
    Type Description
    Number Currency amount after the conversion.

    This example assumes a conversion rate of 1 Euro = .92 US dollars.

    var conv = new sn_currency.GlideCurrencyConverter('EUR', 'USD');
    conv.setAmount(100);
    var convertValues = conv.convert();
    gs.info('Exchanged Amount: ' + convertValues.getAmount());

    Output:

    Exchanged Amount: $92.00

    Scoped GlideCurrencyExchangeValue - getCurrency()

    Returns the converted to currency type.

    Table 3. Parameters
    Name Type Description
    None
    Table 4. Returns
    Type Description
    String Three-letter ISO currency code of the converted to currency.
    var convertValues = new sn_currency.GlideCurrencyConverter('USD', 'JPY');
    convertValues.setAmount(100);
    gs.info('Exchanged Currency (To): ' + convertValues.convert().getCurrency());

    Output:

    Exchanged Currency (To): JPY

    Scoped GlideCurrancyExchangeValue - getOriginalCurrency()

    Returns the original, pre-conversion currency type.

    Table 5. Parameters
    Name Type Description
    None
    Table 6. Returns
    Type Description
    String Three-letter ISO currency code of the currency converted from.
    var converter = new sn_currency.GlideCurrencyConverter('USD', 'JPY');
    converter.setAmount(999.999)
    var convertValues = converter.convert();
    gs.info('Original Amount: ' + convertValues.getOriginalCurrency());

    Output:

    Original Amount: USD

    Scoped GlideCurrencyExchangeValue - getOriginalValue()

    Returns the original, pre-conversion amount.

    Table 7. Parameters
    Name Type Description
    None
    Table 8. Returns
    Type Description
    Number Original amount before conversion.
    var converter = new sn_currency.GlideCurrencyConverter('USD', 'JPY');
    converter.setAmount(999.999)
    var convertValues = converter.convert();
    gs.info('Original Amount: ' + 'convertValues.getOriginalAmount());
    

    Output:

    Original Amount: 999.999

    Scoped GlideCurrencyExchangeValue - getRate()

    Returns the exchange rate used during the conversion.

    Table 9. Parameters
    Name Type Description
    None
    Table 10. Returns
    Type Description
    Number Exchange rate used in the currency conversion.
    var converter = new sn_currency.GlideCurrencyConverter('EUR', 'USD');
    converter.setAmount(999.999)
    var convertValues = converter.convert();
    gs.info('Original Amount: ' + convertValues.getRate());

    Output:

    Exchange rate: 1.0559

    Scoped GlideCurrencyExchangeValue - getRateSysId()

    Returns the sys_id of the record in the rate table used in the currency conversion.

    Table 11. Parameters
    Name Type Description
    None
    Table 12. Returns
    Type Description
    String Sys_id of the rate table used in the currency conversion.
    var converter = new sn_currency.GlideCurrencyConverter('USD', 'JPY');
    converter.setAmount(999.999)
    var convertValues = converter.convert();
    gs.info('Rate table sys_id: ' + convertValues.getRateSysId());

    Output:

    Original Amount: 99ebb4156fa831005be8883e6b3ee4b9