You are viewing limited content. For full access, please sign in.

Question

Question

Change Currency Type Based on Drop Field Selection

asked on March 29, 2017 Show version history

Would anyone know if its possible to change the currency type of a currency field based on the input of a drop down?

 

If yes, any suggestions on how to get started with the javascript/css for that?

 

Thanks

 

Edit: I should add I that I've copied the list of items that can be chosen in the currency field options into my drop down list where users are selecting the currency type.

0 0

Answer

SELECTED ANSWER
replied on March 30, 2017 Show version history

Hi Evan,

Here is an example:

First, make sure the drop-down field choices/values all start with currency code as shown in field options (like "USD - US Dollar($)"). This will be used to find choice symbol. Add CSS class "currencyFormat" to the drop-down field.

Then, apply the following script

$(document).ready(function(){
  var currencyFormat = '';
  //When currency format is changed, update currency fields
  $('.currencyFormat select').change(function(){
    currencyFormat = $('.currencyFormat select').val().substring(0,3);
    UpdateCurrency();
  });
  //If form is read only, get currency format from text and update fields
  if ($('.currencyFormat .ro')) {
    currencyFormat = $('.currencyFormat .ro').text().substring(0,3);
    UpdateCurrency();
  }
  function UpdateCurrency()
  {
    if (currencyFormat) {
  	  $('input.currency').attr('currencyformat', currencyFormat);
      //Update field symbol
      $('span.margin-end').each(function () {
            currency = _.find(currency_list, { 'code': currencyFormat});
            $(this).text(currency['symbol']);
		});
    }
  }
})

p.s. I tried to update currency decimal place as well but it didn't work as expected. So currency decimal place could not be changed with above code.

1 0
replied on March 30, 2017

Thank you Rui!  Worked like a charm.

0 0

Replies

replied on July 31, 2019

Hi All,

 

Can I raise this as a feature request, to have a Currency picker option as a drop down in a currency field? Just a tick box saying, allow user to change currency would probably do it in the field confiuration options.

 

If you're a multi national bank, you'll have to create a BP for each currency if you want to use a currency field, you could probably use field rules or a drop down to do this also, but that's very long winded for something so simple.

 

Cheers!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.