Is there a problem with my javascript on a custom button? Before it was set to URL with the URL variable filled in, but now i want to add logic to this.



var url = '/apex/QuoteRequestDetailsPage?QuoteRequestId={!Quote_Request__c.Id}

  • If there really is a line break before &OpportunitySegmentId that is a problem.
    – Keith C
    Commented Sep 16, 2016 at 16:36

1 Answer 1


You can't use a literal newline in a JavaScript string. This causes an "unterminated string" parsing error.

To fix it, use string concatenation:

var url = '/apex/QuoteRequestDetailsPage?'+

Personally, I'd recommend using URLFOR:

var myUrl = "{!URLFOR($Page.QuoteRequestDetailsPage, null,
window.open(myUrl, "_self");

URLFOR will take care of all the pesky details of encoding, line breaks, and so on.

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