Always use selected currency, having multiple currencies

Duodecimal
Mega Guru

I'm developing an invoice tracker for an international department and am running into an issue with localization.

A department needs to see the correct currency for each invoice. But if a locale is set properly for each user, it converts the shown amount into their local currency. With no locale, it defaults to system (US dollars).

 

Is there a way to fix a currency field to always show the original currency selected to all users? No dictionary attribute seems to be specific to the currency field

 

Current behavior

(UK user)

Invoice 1         £3521.17

Invoice 2         £3,500.00

Invoice 3         £8763.22

(US user)

Invoice 1         $5,000.00

Invoice 2         $4,739.11

Invoice 3         $9,219.83

 

Desired behavior:

(All users)

Invoice 1         $5,000.00

Invoice 2         £3,500.00

Invoice 3         CHF 10,000.00

 

Am I just going to have to bite the bullet and recreate these fields as decimals with a separate field for currency? That would be heinous.

1 ACCEPTED SOLUTION

Duodecimal
Mega Guru

I replied to another thread by Michel Conter -- he got pointed to a solution that SN disavows support of (since it's a customization, I'd guess).



The wiki does have an article or two about using Fixed Currency, but since it was in relation to catalog items I moved on and couldn't find anything more specific. I should have paid closer attention.



If you do set a field as Price type, an "Edit" link appears next to it when it's displayed on the form, which when clicked sends you to the matching record in the fx_price table. That record has a type field that you can change it from Multiple Currencies to Fixed. Once it's set to Fixed, it stays there.



You can create an after insert/update business rule that watches for changes to your price field that you want to keep in their original currencies, and have them update their matching record in fx_price to set the type to "fixed".



Since I had many such fields, I created a script include to handle this:



function setPriceAsFixed(grID, fld) {


  var p = new GlideRecord("fx_price");


  p.addQuery("id", grID);


  p.addQuery("field", fld);


  p.addQuery("type", "!=", "fixed");


  p.query();


  if (p.next()) {


          p.type = "fixed";


          p.update();


  }


}



My version of that takes fld as an array and uses p.addQuery("field", "IN", fldArr) instead of that listed addQuery line (along with using a while(p.next())) , since some of my invoicing tables have multiple price fields per record.


fixed_prices.png


View solution in original post

5 REPLIES 5

Duodecimal
Mega Guru

I replied to another thread by Michel Conter -- he got pointed to a solution that SN disavows support of (since it's a customization, I'd guess).



The wiki does have an article or two about using Fixed Currency, but since it was in relation to catalog items I moved on and couldn't find anything more specific. I should have paid closer attention.



If you do set a field as Price type, an "Edit" link appears next to it when it's displayed on the form, which when clicked sends you to the matching record in the fx_price table. That record has a type field that you can change it from Multiple Currencies to Fixed. Once it's set to Fixed, it stays there.



You can create an after insert/update business rule that watches for changes to your price field that you want to keep in their original currencies, and have them update their matching record in fx_price to set the type to "fixed".



Since I had many such fields, I created a script include to handle this:



function setPriceAsFixed(grID, fld) {


  var p = new GlideRecord("fx_price");


  p.addQuery("id", grID);


  p.addQuery("field", fld);


  p.addQuery("type", "!=", "fixed");


  p.query();


  if (p.next()) {


          p.type = "fixed";


          p.update();


  }


}



My version of that takes fld as an array and uses p.addQuery("field", "IN", fldArr) instead of that listed addQuery line (along with using a while(p.next())) , since some of my invoicing tables have multiple price fields per record.


fixed_prices.png