Math functions on a variable of type currency

I was struggling to do a math function on a variable set as type currency. I know that math functions on currency are coming in release 17.15, but I was looking for away to achieve this in the interim. I was about to do a convoluted hack of converting the currency to a string, string to number, then multiply the number, and then take it back to a currency, but found out that currency is an object that contains an amount attribute that is the numerical value of the currency. So if I have a currency variable called ‘myCurrency’, i can do math on it by addressing myCurrency.amount * whatever.

2 Likes

Welcome, and great call out! When using the currency type, the object will looks something like this:

{
  "amount": 12300,
  "code": "USD",
  "precision": 2
}

Which means you can use the amount property and do any math accordingly.

1 Like