-Dman100-
asked on
number outside valid range
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_Patie nt_Revenue __c', message:'Net Patient Revenue: value outside of valid range on numeric field: NaN', statusCode:'NUMBER_OUTSIDE _VALID_RAN GE',},id:n ull,succes s: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.
{errors:{fields:'Net_Patie
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.
{!requireScript("/soap/ajax/11.1/connection.js")}
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 = "https://cs4.salesforce.com/" + "{!Account.Id}";
}
else {
alert ("{!$User.FirstName} a new lead has been created for "+ answer1 +" "+ answer2 );
retURL = "https://cs4.salesforce.com/" + lid;
}
window.location.href = retURL;
It looks like you are "mixing" javascript with SOMETHING_ELSE? What is that "something_else"? I'm trying to understand on what line you are getting that error. Also, where does Account come from?
ASKER
I'm using Javascript and the Salesforce AJAX toolkit with allows to connect thru their API. So, the account is coming from Salesforce using merge field syntax.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.