how to get currency2 value without including the currency symbol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 02:40 AM
Hello
i want to know how to get currency2 value without including the currency symbol
"EUR;10"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 02:47 AM
Depending on the context you could do some other things, but just for that example lets say your currency is stored in variable "currency".
You could just try something like this
var currency = "EUR;10";
var price = currency.split(";")[1];
gs.info(price);
Here we have the currency value stored in a variable and we use split(";") to create an array or currency where each value is separated by the semicolon. This results in an array like ["EUR","10"]. By adding [1] we tell that we want the value in second index, which would be the actual numerical price.
If you have a currency symbol in the resulting value, you can also use .substring(1) to remove the first character.
So for example €10 would become 10.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 04:14 AM
I thought there was a JavaScript method to do it directly because I'm looking for the best practice to build my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 05:12 AM
Well, it depends on how you're getting the price. I assumed you had the currency as a string, but if you have the currency field, then there are few things you can do.
Below's a list of scripts and their results.
Price 88USD and script run as user who sees euros.
current.price: 80.86
current.price.getReferenceCurrencyCode(): USD
current.price.getReferenceDisplayValue(): USD88.00
current.price.getReferenceValue(): 88
current.price.getSessionCurrencyCode(): EUR
current.price.getSessionDisplayValue(): €80.86
current.price.getSessionValue(): 80.86
current.price.getCurrencyCode(): USD
current.price.getCurrencyDisplayValue(): USD88.00
current.price.getCurrencyString(): EUR;80.86
current.price.getCurrencyValue(): 88
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 04:01 AM
Hello....
can you elaborate on this method, like i have a table accounts with a field 1-30 which is a 'FX CURRENCY' type and contains values like $157,000 ...... etc , now i want to display this value in a vertical bar component but cant pass this value to it.......i tried doing
can you help me with the code or approach to get this result.
Thank You.