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
NapsterNapster 

Unexpected Token : Illegal (Custom JS button)

Hi friends, 

I am facing an error which i get when i click on my custom JS button. The browser returns a Unexpected Token : Illegal when trying to execute. I am not able to figure out why. Your help is greatly appreciated. 

Here is the button code :
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")} 
{!REQUIRESCRIPT("/resource/jquery_1_9_1_min")} 
{!REQUIRESCRIPT("/resource/JQueryBlockUI")} 
{!REQUIRESCRIPT("/apex/LaunchApplications")} 

var filter = "{!CASE(Opportunity.Type , "Presale - X", "Presale - X", "Renewal - ZR", "Renewal - ZR", "Off Renewal - Y", "Off Renewal - Y", "RFI", "RFI", "Target Prospect", "Target Prospect", "NonCPP")}"; 

launchForms({!Opportunity.Id}, {!Opportunity.AccountId},{!$Api.Session_ID},filter )

This is the Page where the logic takes place : 

<apex:page contentType="text/javascript" showHeader="false" standardStylesheets="false">
  
 function launchForms(OptyId, acctId, sessionId, filter)
    {
		
		var url = "/apex/loop__looplus?eid="+OptyId+"&amp;accountId="+acctId+"&amp;sessionId=" +sessionId+ "&amp;sidebar=false&amp;filtertype=contains&amp;filter="+filter;
		var query = "SELECT ContactId__r.Name, ContactId__r.Email, Role__c FROM OpportunityContactRoleExt__c WHERE OpportunityId__c="+OptyId+" ORDER BY Contact_Name__c";
		
		var contactRoles = sforce.connection.query(query);
		
		var foundOne = false;
		
		if (contactRoles &amp;&amp; contactRoles.size &gt; 0) {
		for (var i = 0; i &lt; contactRoles.size; i++) {
		var c = (contactRoles.records[i] ? contactRoles.records[i] : contactRoles.records);
		
		if (c.Role__c == "PPACA Contact") { 
		foundOne = true;
		url += ' PPACA,';
		url += "&amp;noa="+encodeURIComponent(c.ContactId__r.Name)+","+encodeURIComponent(c.ContactId__r.Email);
		break;
		}
		}
		
		}
		if (!foundOne) url += ',';
		
		window.open(url,OptyId,'height=600,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes');
                
    }

</apex:page>

Thanks folks in advance.. :)

Raja ReddyRaja Reddy
Napster,

You should change the JS version above 28.0(or the latest(32.0) as per the current Release)

AJAX Toolkit Support Policy:
------------------------------------
The current release of the AJAX Toolkit(32.0) is the only version that receives bug fixes and enhancements. When a new version is released, the previous version continues to be available, but is not supported.

For more info: http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax_introducing.htm#ajax_support_policy_title

Please have a look on https://success.salesforce.com/answers?id=90630000000gyHqAAI