You need to sign in to do that
Don't have an account?
Losintikfos
JavaScript Error
I am using a JavaScript to pass BillingStreet field to an appex script and keeps poping up with the error below;
A problem with the OnClick JavaScript for this button or link was encountered:
unterminated string literal.
When i pass in AccountAlias it works.
Do anyone knws whats' happening? do i need to do do some validity checks on the billing field?
pls. Hlp.
Message Edited by Losintikfos on 10-03-2008 03:18 AM
A problem with the OnClick JavaScript for this button or link was encountered:
unterminated string literal.
When i pass in AccountAlias it works.
Do anyone knws whats' happening? do i need to do do some validity checks on the billing field?
pls. Hlp.
Message Edited by Losintikfos on 10-03-2008 03:18 AM
The script works perfect on sandbox - this issues only happends when i deploy to production.
Any Help!
Message Edited by Losintikfos on 10-03-2008 03:01 AM
Could be that the data you're using has an apostrophe in it or a quote, which JS is interpreting as the end of a string. So if you have:
var contactName = '{!Contact.Name}';
But the guy's name is Jim O'Malley, then it will turn out as:
var contactName = 'Jim O'Malley';
And Javascript will think that the string is 'Jim O', Malley makes no sense, and another string starts after the Malley - hence the unterminated string.
I am doing something like this;
works perfect, it is only the Street. I did some research on the web and it says it might be some breaks in the address field fetched but dont know how to handle it.
Any ideas?
Message Edited by Losintikfos on 10-03-2008 08:06 AM
Instead of using the merge variable directly, put it in a html tag and then get the value from the DOM. (There are some discussion threads on this if you look for "textarea"). E.G.
<input type="hidden" id="peanuts">{!my_merge_field}</input>
and later:
var my_value = Document.getElementById('peanuts").value;
Hope this helps, Steve.
Hi SteveBower,
Base on your advice, i am doing something like this;
<input type="hidden" id="billing">{!Account.BillingStreet}</input>
var streetC = Document.getElementById('billing").value;
And still gets the same error!
Any advice pls?
B
Need your help experts!:smileysad:
Message Edited by Losintikfos on 10-06-2008 02:24 AM
Here's a dumb question.... if you're trying to pass information into an Apex class, why bother trying to pass specific fields from the Account object?
Why not just pass the Account Id, and let the Apex class do the select and get the fields it needs itself. This way if you ever need to make changes, you can just change the class and not have to touch the javascript.
However.... in your example, you are missing quotes around BillingStreet merge field. Aside from that, if you are able to assign it to "document.getElementById("billing").value", then you would also be able to assign it to "var streetC = " in the first place. After all, they are *both* just javascript variables.
I'm not sure I have an answer for you. I'd just pass in the ID value. Steve.
p.s. Are you using debugging tools for your javascript? Firebug is an excellent Add-on for Firefox.
Did follow your advice and it worked perfectly well!
tHANKS FOR A GOOD ADVICE :smileywink: