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

Question

Question

Currency Formatting Not Displaying on Form Saved to Repository

asked on March 13, 2017

I have javascript included in my form that I thought would display all currency fields in the $0.00 format; however, it is not working properly.  An example would be that $115.00 is being displayed as $115 on the form.  The form is being submitted by Workflow, and then routed to a user for verification and final edits.  Once that user approves the form, both the original and another abbreviated version of the form are being saved to the repository (form saved with current process data).  I have attached the javascript I am using.  Some of the fields are formulas calculated by forms, some fields are filled in by Workflow on the initial submission.  It doesn't seem to matter which way they are completed, they still do not display properly for me.  We are running Forms 10.1.

Any help would be appreciated.

 

Thanks!

$(document).ready(function(){
    
  //when any currency field input is changed, round the number to 2 decimal places
  $('.currency').change(function() {
    $(this).val(formatCurrency($(this).val()));
  });
  
  function formatCurrency(value) {
    var float = parseFloat(value);
    return isNaN(float) ? 0 : (Math.round(float*100)/100).toFixed(2);
  }
  
  function roundDecimal(val, precision) {
  return (Math.round(Math.round(val * Math.pow(10, precision+1))/10)/Math.pow(10, precision)).toFixed(precision);
  }

});

 

0 0

Answer

SELECTED ANSWER
replied on March 13, 2017

Hi Melanie,

When value is from formula or carried value, there is no "change" event triggered on form so your custom script could not cover the case.

You could add script to format currency field on form load like this:

$('.currency').each(function() {
    $(this).val(formatCurrency($(this).val()));
  });
0 0

Replies

replied on March 14, 2017

Thank you so much!  I had a feeling it was the "change" wording that was causing the issue, but didn't know the proper way to address fields that were just being loaded on the form, not changed.  This fixed the issue.

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

Sign in to reply to this post.