client script g_form.setValue() stores currency value above $10m stores exponential notation value

mkm1
Mega Guru

In my client script, please refer the following original script where I am using a client script to set value to a field. When the currency value is above or equal to $10,000,000.00 it sets the value to exponential notation value (1.0E7) i.e., for $10million it's setting it to $1.07. Any value below $10m work fine.  For debugging, I have tried convert the value using parseFloat or float, var v_float = parseFloat(v_cvalue), variable v_float shows the correct value but does not work.
  .

 

function getFunded(response) {
v_cvalue = response.responseXML.documentElement.getAttribute("answer");


g_form.setValue('tot_funded_amt', v_cvalue);

}

 

Screen shot for debugging g_form.addInfoMessage('v_cvalue:'+v_cvalue) and g_form.addInfoMessage('v_float:'+ v_float); as below:

mkm1_0-1688856284626.png

 

1 ACCEPTED SOLUTION

Following code solved the problem.  The parseFloat() function parses a string argument and returns a floating-point number. The toFixed() method returns a string representation of the number with the specified number of decimal places. 
function getFunded(response) {
        v_cvalue = parseFloat(response.responseXML.documentElement.getAttribute("answer"));
var decimal_value = v_cvalue.toFixed(0);
 
        g_form.setValue('tot_funded_amt', decimal_value);

}

View solution in original post

3 REPLIES 3

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @mkm1 

Greetings!

This generally happens when the type is number.

Can you try with

v_cvalue = response.responseXML.documentElement.getAttribute("answer").toString();

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra.

 

Hi Ravi, Thanks for your suggestion. No this didn't solve the problem.

Following code solved the problem.  The parseFloat() function parses a string argument and returns a floating-point number. The toFixed() method returns a string representation of the number with the specified number of decimal places. 
function getFunded(response) {
        v_cvalue = parseFloat(response.responseXML.documentElement.getAttribute("answer"));
var decimal_value = v_cvalue.toFixed(0);
 
        g_form.setValue('tot_funded_amt', decimal_value);

}