You need to sign in to do that
Don't have an account?
JavaScript Error ILLEGAL TOKEN from textarea with line feed
I'm a relative newbie looking for some help. Don't laugh, you were there once, too.. :(
Here's the deal. We have a custom link (button) on a standard account page. The javascript is supposed to take the value of the custom physical_address__c field (textarea) and copy it to the standard BillingAddress fields (BillingStreet, BillingCity, etc).
Everything works when there is only one line in the custom field; but if the user has entered a line feed / carriage return (as many do), the script produces an ILLEGAL TOKEN error.
I've read everything I could find about stripping line feeds out using javascript, but so far no luck. I suspect it's because I haven't figured out how to strip the characters before assigning the field value to a javascript variable. Original code is below, for reference.
Any help out there? I would really appreciate it..
Thanks,
Lewis
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var a = new sforce.SObject("Account");
a.id = "{!Account.Id}";
a.BillingStreet = "{!Account.Physical_Address__c}";
a.BillingCity = "{!Account.Physical_City__c}";
a.BillingState = "{!Account.Physical_State__c}";
a.BillingPostalCode = "{!Account.Physical_Postal_Code__c}";
a.BillingCountry = "{!Account.Physical_Country__c}";
result = sforce.connection.update([a]);
window.location.reload();
What does the source look like when the page errors out? You should be able to View Source and see how the merge fields are being resolved, perhaps a first step to fixing the problem.
Mike
Try using this... let me know if it works.....
This is for those who are also encountering this issue. There is a much easier way to fix this:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var a = new sforce.SObject("Account");
a.id = "{!Account.Id}";
a.BillingStreet = "{!URLENCODE( Account.Physical_Address__c )}";
a.BillingCity = "{!Account.Physical_City__c}";
a.BillingState = "{!Account.Physical_State__c}";
a.BillingPostalCode = "{!Account.Physical_Postal_Code__c}";
a.BillingCountry = "{!Account.Physical_Country__c}";
result = sforce.connection.update([a]);
window.location.reload();
You may want to do the same approach with any fields you are using with funny characters.