Search code examples
javascriptodatadynamics-crmdynamics-crm-2015dynamics-crm-2016

Unable to assign decimal variable in Javascript [CRM Online 2016]


I've got something puzzling me here and I don't have the experience behind me to spot the issue, so I ask your kind assistance.

I'm developing for CRM Online 2016 and I'm trying to extrapolate a value from another entity using oData. I have managed to get the value of 0.2 from the source entity but when I try and assign this to a variable, the value 0.2 becomes 0. See below:

Picture1:

Image showing value contained in results.new_Rate

Picture2:

Image showing value assigned to variable

I've only initialised the variables for testing purposes. How can I pass/use the value contained in results.new_Rate? I'm looking to use this as a percentage in a Tax calculation.

Many Thanks


Solution

  • Declare your variable with this method:

    var taxRate = parseFloat((0.00).toFixed(2));

    The method "toFixed" keeps only two decimals.