• LButler
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

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();