troubleshooting Question

number outside valid range

Avatar of -Dman100-
-Dman100-Flag for United States of America asked on
3 Comments1 Solution1706 ViewsLast Modified:
I am using the following javascript code to insert a new lead record (see code below).  I'm getting the following error for some records that do not have a net patient revenue field:

{errors:{fields:'Net_Patient_Revenue__c', message:'Net Patient Revenue: value outside of valid range on numeric field: NaN', statusCode:'NUMBER_OUTSIDE_VALID_RANGE',},id:null,success:false',}

I've tried multiple ways to overcome this error.  When the net patient revenue record does not exist, I just want to assign the value as zero.

Thanks for any help.

var netPatientRev; 
if ("{!Account.NetPatientRevenue__c}" != null) { 
netPatientRev = "{!Account.NetPatientRevenue__c}"; 
netPatientRev = netPatientRev.replace("$", ""); 
netPatientRev = netPatientRev.replace(/,/g, ""); 
netPatientRev = parseFloat(netPatientRev); 

var lead = new sforce.SObject("Lead"); 
var answer1 = prompt ("What is First Name?"," "); 
var answer2 = prompt ("What is Last Name?"," "); 
lead.Company = "{!Account.Name}"; 
lead.Account__c = "{!Account.Id}"; 
lead.Street = "{!Account.ShippingStreet}"; 
lead.City = "{!Account.ShippingCity}"; 
lead.State = "{!Account.ShippingState}"; 
lead.PostalCode = "{!Account.ShippingPostalCode}"; 
lead.Country = "{!Account.ShippingCountry}"; 
lead.Net_Patient_Revenue__c = netPatientRev; 
lead.Phone = "{!Account.Phone}"; 
lead.Med_Surg_Beds__c = "{!Account.Bed_Size__c}"; 
lead.Website = "{!Account.Website}"; 
lead.Firstname = answer1 
lead.LastName = answer2 
lead.LeadSource = "Other"; 
result = sforce.connection.create([lead]); 

var lid = result[0].id; 
var retURL; 
if (lid == null) { 
alert ("{!$User.FirstName} the lead insert failed for "+ answer1 +" "+ answer2 + ". Please try again."); 
retURL = "" + "{!Account.Id}"; 
else { 
alert ("{!$User.FirstName} a new lead has been created for "+ answer1 +" "+ answer2 ); 
retURL = "" + lid; 
window.location.href = retURL;

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros