I created a custom button for custom object to place in the related list. The custom object has two look-ups, one for case and one for account. This button, when clicked, should open in a new window to save a record of the custom object, with the default values for each look-up to populate automatically depending on the record where the button was clicked. It works for every record so far, except one case. It then throws the error: A problem with the Onclick Javascript for this button or link was encountered: Unexpected identifier.

I couldn't find any differences between records where it works and doesn't.



1 Answer 1


Use JSENCODE, because your account name has an apostrophe (single quote), which causes the string to be malformed. It needs to be properly escaped for JavaScript to not parse it incorrectly.

  • That was the problem. The instance causing the error had an apostrophe in the account name. Thank you!
    – Ian Bury
    Commented Jan 21, 2015 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .