Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Web-development
  3. Question
Web-development

Uncaught SyntaxError: Unexpected identifier because of special characters and foreign language names present in Account

Asked by Isaac Ross Aug 1, 2021 1.7K views 1 answer
Share

About this question

 I have developed page with autoComplete feature. I'm getting an Uncaught SyntaxError: Unexpected identifier error because of symbols used in Account Names such as "诸城金盛-abc Commerce and" Co., Ltd. I'm posting my code for reference.

Visualforce page Code:

<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Autocomplete - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <style> .ui-autocomplete { max-height: 100px; overflow-y: auto; overflow-x: hidden; } * html .ui-autocomplete { height: 100px; } td.data2Col { text-align: center !important; } table { border:0px; border-collapse:collapse; border-spacing:0px; } td,th { padding:0px; border-width:0px; margin:0px; } th{ width : 50px !important; } th{ width : 50px !important; padding-bottom: 20px; } table#mytable tr td:first-child{display:none;} table#mytable th{width:12%} table#mytable td{text-align:left;} </style> [removed][removed] [removed][removed]

[removed] $( function() { var availableTags = {!accList}; $('[id$=AccountIds]').autocomplete({ source: availableTags }); } ); [removed]

Apex Code:

public class SFI_AccountExtension { public Account accountRecord { get; set; } public List < String> accList { get; set; } public String selectedAccount{ get; set; } public SFI_AccountExtension(ApexPages.StandardController sc) { selectedAccount = ''; accountRecord = (Account) sc.getRecord(); getAccountList();//method to load list of accounts } //Method to supply list of account with the record type name 'SAP Sold-To Customer' present in salesforce for auto complete public List < String> getAccountList() { accList = new List < String> (); Id RecordTypeId = [SELECT Id, Name FROM RecordType WHERE SobjectType = 'Account' AND Name = 'SAP Sold-To Customer' limit 1 ].id; for (Account acc: [select name, SAP_Customer_Number__c from Account where recordTypeId =: RecordTypeId]) { accList.add('"' + acc.SAP_Customer_Number__c + ' - ' + acc.name + '"'); } return accList; } }

Why getting syntaxerror: unexpected identifier? Can somebody please tell how to avoid this type of error.

Your answer

1 Answer

More Web-development discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest from the JanBask Blog

Guides, tips and career advice from JanBask experts.