1

I've tested the following scenario after tracking down a bug. Can anyone else confirm this is an issue with Salesforce or am I missing something?

Replication steps:

  1. create a 14-4 percent field on Contact
  2. populate the field on a new Contact 'frank smith' with '12345678901234.1234'
  3. setup a javascript remoting call to get 'frank smith' and the new percent field
  4. inspect the result from the javascript remoting call and observe the result is '12345678901234.123'

Sample VF page:

<apex:page showHeader="true" sidebar="true" controller="Ctl_TestPercent">
<head>
<script>
var findCon = '{!$RemoteAction.Ctl_TestPercent.findCon}';

Visualforce.remoting.Manager.invokeAction(  
findCon,
function(result, event) {
    // if there was an error
    if (event.type=='exception') {              
        alert(result);
        console.log('error result:' + result);
    }
    // if there was no error continue
    else {
        console.log(result);
        document.getElementById('jsresult').innerHTML=JSON.stringify(result);
    }
}
);

</script>
</head>
<body>
<!--  standard result -->
{!con.percent_14_4__c}
<!-- remoting result -->
<div id="jsresult"></div>
</body>
</apex:page>

controller (insert the new contact's ID in the two queries) :

public with sharing class Ctl_TestPercent {
    public Contact con {get;set;}

    public Ctl_TestPercent() {
        con = [SELECT Id,Percent_14_4__c FROM Contact WHERE Id='INSERT ID'];
    }

     @remoteAction
    public static Contact findCon() {
        Contact thisCon = [SELECT Id,Percent_14_4__c FROM Contact WHERE Id='INSERT ID'];
        return thisCon;
    }
}
  • 1
    Try serializing/parsing a JSON string to get around the limitation that @Ashwani mentioned. – Moshe Karmel Aug 14 '15 at 21:13
  • @MosheKarmel thats a good idea, appreciate it! – Phil B Aug 14 '15 at 21:16
0

It is not a limitation or bug in Salesforce.

It is the limitation of Javascript memory allocation of a number with decimals. You can not go beyond 17 digits and 64 bit (approx.) number which has decimal in it.

In javascript, the maximum number of decimals is 17, technically Sign 1 bit (63) bit

See following examples:

var n = 12345678901234.1234;
console.log(n+'  '+((n+'').length));
12345678901234.123  18

var n = 92345678901234.1234;
console.log(n+'  '+((n+'').length));
92345678901234.12  17

Even many other languages and database column types have such limitation including Salesforce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.