You need to sign in to do that
Don't have an account?
shivangi shailesh 8
Need to update the calculation logic for snapshot to allow a 0/0 formula that results in NaN cannot be converted from text to number - must calculate to zero
Hi ,
function validateFormula(){
console.log("start validateFormula");
var formula = "{!SLA_Snapshot__c.Formula__c}";
var A = document.getElementById("{!$Component.frm.A}") ? document.getElementById("{!$Component.frm.A}").value : "";
var B = document.getElementById("{!$Component.frm.B}") ? document.getElementById("{!$Component.frm.B}").value : "";
var C = document.getElementById("{!$Component.frm.C}") ? document.getElementById("{!$Component.frm.C}").value : "";
var D = document.getElementById("{!$Component.frm.D}") ? document.getElementById("{!$Component.frm.D}").value : "";
var E = document.getElementById("{!$Component.frm.E}") ? document.getElementById("{!$Component.frm.E}").value : "";
var snapFormulaWithValues = formula.replace('A',A).replace('B',B).replace('C',C).replace('D',D).replace('E',E);
try{
var result = eval(snapFormulaWithValues);
document.getElementById("{!$Component.frm.ResultValue}").innerText = result.toFixed(2);
document.getElementById("{!$Component.frm.ResultValueHidden}").value = result.toFixed(2);
if(document.getElementById("{!$Component.frm.ResultValue}").innerText.includes("NaN"))
{
document.getElementById("{!$Component.frm.ResultValue}").innerText = "not available";
}
Formula is (A/B)*100 .pLEASE TELL WHERE TO HANDLE THIS SO THAT SOMETHING WILL HAPPEN LIKE
iF A =0 AND B=0 the result should be '0' but currently NAN ERROR IS COMING.
function validateFormula(){
console.log("start validateFormula");
var formula = "{!SLA_Snapshot__c.Formula__c}";
var A = document.getElementById("{!$Component.frm.A}") ? document.getElementById("{!$Component.frm.A}").value : "";
var B = document.getElementById("{!$Component.frm.B}") ? document.getElementById("{!$Component.frm.B}").value : "";
var C = document.getElementById("{!$Component.frm.C}") ? document.getElementById("{!$Component.frm.C}").value : "";
var D = document.getElementById("{!$Component.frm.D}") ? document.getElementById("{!$Component.frm.D}").value : "";
var E = document.getElementById("{!$Component.frm.E}") ? document.getElementById("{!$Component.frm.E}").value : "";
var snapFormulaWithValues = formula.replace('A',A).replace('B',B).replace('C',C).replace('D',D).replace('E',E);
try{
var result = eval(snapFormulaWithValues);
document.getElementById("{!$Component.frm.ResultValue}").innerText = result.toFixed(2);
document.getElementById("{!$Component.frm.ResultValueHidden}").value = result.toFixed(2);
if(document.getElementById("{!$Component.frm.ResultValue}").innerText.includes("NaN"))
{
document.getElementById("{!$Component.frm.ResultValue}").innerText = "not available";
}
Formula is (A/B)*100 .pLEASE TELL WHERE TO HANDLE THIS SO THAT SOMETHING WILL HAPPEN LIKE
iF A =0 AND B=0 the result should be '0' but currently NAN ERROR IS COMING.