I encounter this error:

missing ) after argument list in javascript salesforce

when running the following:


  • Can Some one help me what is missing there .. it worked perfectly fine till today morning .. but suddenly i got the error some argument is missing – Revanth Mar 9 '16 at 18:47
  • 2
    If the Account name includes a single quote the JavaScript would then be invalid. What is the Account name when this fails? Using {!JSENCODE(Account.Name)} would protect against that.. – Keith C Mar 9 '16 at 18:50
  • if('{(!Account.Account_Checked__c)}'==1) I tried but still getting the same error – Revanth Mar 9 '16 at 18:55
  • It does not sound like you used the advice from @KeithC then. You need to encode your strings using JSENCODE() to prevent invalid characters from creeping into your javascript string. – dsharrison Mar 9 '16 at 19:15
  • @KeithC Just post that as an answer! Seems likely enough to be the root cause. I'd upvote. – Adrian Larson Mar 9 '16 at 19:22

If the Account name includes a single quote the JavaScript would then be invalid because that single quote would be interpreted as a string delimiter.

Using {!JSENCODE(Account.Name)} would protect against that as described in the JSENCODE documentation:

Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (), before unsafe JavaScript characters, such as the apostrophe (').

  • Could you maybe also explain how to make this button work across environments? I notice the link structure is https://c.ap12.visual.force.com/..., which seems very brittle. – Adrian Larson Mar 9 '16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.