Search code examples
javascriptdynamics-crm

parseFloat() function parses an argument and returns a floating point number but with me after using it Retrieve Nan


In my Form there is (whole number Field in CRM ) and in JavaScript that retrieve value I used ParseFloat function but retrieved to me NaN but I want to Retrieve like (12.00).

function SetLookup(fieldName, Id, Name, LogicalName) 
{
    var value = new Array();
    value[0] = new Object();
    value[0].id = Id;
    value[0].name = Name;
    value[0].typename = LogicalName;
    var getAttribute = Xrm.Page.getAttribute(fieldName);
    if (getAttribute != null) {
        getAttribute.setValue(parseFloat(value));
        getAttribute.setSubmitMode("always");
    }
}

Solution

  • parseFloat() expects a string input. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat

    However your code tries to pass it an array of objects.