You need to sign in to do that
Don't have an account?

OnClick JavaScript Error
Hello - Here's my code for my Request Validation Button on a lead.
I got this error

I found out that this error happens if the address is filled in as two lines, because it's a "long text" field maybe?
If the street field is filled out as "1008 W. 8th Avenue, Ste. E" It is okay. But as soon as it becomes two lines, like this
"1008 W. 8th Avenue
Ste. E" it throws this error.
Can someone tell me what i can do about this?
Thanks!
I got this error
{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")} var leadAddress = '{!Lead.Street}'; var leadCity = '{!Lead.City}'; var leadState = '{!Lead.State}'; var leadCountry = '{!Lead.Country}'; var leadZip = '{!Lead.PostalCode}'; if(leadAddress == null || leadAddress == ''){ alert('Please enter a valid Street Address along with the City, State/Province, Zip/Postal Code and Country before clicking on this button.'); } else if(leadCity == null || leadCity == ''){ alert('Please enter a valid Street Address along with the City, State/Province, Zip/Postal Code and Country before clicking on this button.'); } else if(leadState == null || leadState == ''){ alert('Please enter a valid Street Address along with the City, State/Province, Zip/Postal Code and Country before clicking on this button.'); } else if(leadCountry == null || leadCountry == ''){ alert('Please enter a valid Street Address along with the City, State/Province, Zip/Postal Code and Country before clicking on this button.'); } else if(leadZip == null || leadZip == ''){ alert('Please enter a valid Street Address along with the City, State/Province, Zip/Postal Code and Country before clicking on this button.'); } else{ var urlStr = '/a0J/e?' + 'CF00Nj00000091TUH={!Lead.FirstName &" "& Lead.LastName }' + '&CF00Nj00000091TUH_lkid={!Lead.Id}' + '&retURL=%2F{!Lead.Id}' + '&saveURL=%2F{!Lead.Id}' + '&RecordType=012j0000000pfbL' + '&ent=01Ij0000001EVex' + '&00Nj00000091TU6={!Lead.Company}' + '&00Nj00000091TUQ=Pending'; window.open(urlStr,"_self") }
I found out that this error happens if the address is filled in as two lines, because it's a "long text" field maybe?
If the street field is filled out as "1008 W. 8th Avenue, Ste. E" It is okay. But as soon as it becomes two lines, like this
"1008 W. 8th Avenue
Ste. E" it throws this error.
Can someone tell me what i can do about this?
Thanks!
You will need to replace '<br>' with '\n' in JavaScript.
Any other suggestions?
Can you try this:
If this works, just use JSENCODE then