function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shuang HuShuang Hu 

A problem with the OnClick JavaScript for button "New Quote"

Hi all
When I click button "New Quote" on one Opportunity after adding products, the page shows "A problem with the OnClick JavaScript for this button or link was encountered: unterminated string literal"
But only for one specific Account.

Should I revise the "OnClick JavaScript" for the button?

Thank you,
Medhya MahajanMedhya Mahajan

Please share the Javascript code for the button in order to know what is failing. ( Opportunity --> buttons or links --> New quote )

Medhya Mahajan
Abu HashimAbu Hashim
Hey Shuang, That error of JS mainly occurs when it encounters with Apostrophe or Quotes. May be ur specific account has that criteria and JS is throwing exception. I think, Yes, u should revise the Onclick JS.
Shuang HuShuang Hu
if('{!Opportunity.Account_Record_Type__c}' == 'Indirect Customer'){
window.parent.location.href = "{!Opportunity.Id}&oppid={!Opportunity.Id}&BillingName={!Opportunity.Billing_Account__c}&BillingAddressstreet={!Opportunity.Bill_To_Street__c}&BillingAddresscity{!Opportunity.Bill_To_City__c}&BillingAddressstate={!Opportunity.Bill_To_State_Province__c}&BillingAddresszip={!Opportunity.Bill_To_Zip_Postal_Code__c}&BillingAddresscountry={!Opportunity.Bill_To_Country__c}&CF00N28000005y9lP={!Opportunity.Account}";
window.parent.location.href = "{!Opportunity.Id}&oppid={!Opportunity.Id}&CF00N28000005y9lP={!Opportunity.Account}";
Medhya MahajanMedhya Mahajan

It looks like some data issue. 

The account for which the error is coming might be having single or double quote in the value due to which this URL formation ends as soon as the quote is encountered and the remaining part of the URL is not evaluated leading to the error.

It is suggested to look into the data  of that particular account ( of these fields in the URL of javascript ) to see for ( ' OR  " ).

Mark as solved if this helps.

Medhya Mahajan
Shuang HuShuang Hu
Hi Medhya,
Thank you for your suggestion!
But I don't find single or double quote in the value of this account for now.
Medhya MahajanMedhya Mahajan
Hey Shuang ,

Cannot debug at my end , to me it seems like data issue only. Check every field value thoroughly.

Medhya Mahajan
Shuang HuShuang Hu
Thanks Medhya.  I found the issue is the address of this account.  It should be because I uploaded bulk data to make the addresses of some account not fit the format in salesforce.