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
Ken sfdc1Ken sfdc1 

Onclick Javascript unexpected token illegal javascript

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
if('{!Patient_Insurance__c.Health_Plan_Category__c}'=='Commercial')
{
if('{!Patient_Insurance__c.Health_Plan__c}'==''|| '{!Patient_Insurance__c.Health_Plan_Group_Number__c}'==''||'
{!Patient_Insurance__c.Payor__c}'==''||
'{!Patient_Insurance__c.CoPay_Amount__c}'==''||
'{!Patient_Insurance__c.Coinsurance_Percent__c}'==''||
'{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}'==''||
'{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}'==''||'
{!Patient_Insurance__c.CoPay_Amount__c}'==''||'
{!Patient_Insurance__c.Coinsurance_Percent__c}'== ''||'{!Patient_Insurance__c.Deductable__c}'== ''||'{!Patient_Insurance__c.Deductible_Amount_Met__c}'== ''||'{!Patient_Insurance__c.OOP_Max__c}'==''||'
{!Patient_Insurance__c.OOP_Met__c}'== ''||'{!Patient_Insurance__c.Coinsurance_Percent__c}'=='')
{
alert('Please populate insurance and limit fields before procedding...');
}
else
{
window.location.href = '/500/e?cas4={!Patient_Insurance__c.Patient__c}&00Nc0000001BVbO= {!Patient_Insurance__c.Name}
&retURL=%2F500%2Fo&RecordType=012c00000000aXZ&ent=Case';
}
}
else
{
alert('The health plan category must be equal to Commercial.');
}
Best Answer chosen by Ken sfdc1
@anilbathula@@anilbathula@
Hi Ken Sfdc,

Try this code.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
if("{!Patient_Insurance__c.Health_Plan_Category__c}"=="Commercial")
{
	if("{!Patient_Insurance__c.Health_Plan__c}"==""||
        "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
	"{!Patient_Insurance__c.Payor__c}"==""||
	"{!Patient_Insurance__c.CoPay_Amount__c}"==""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"==""||
	"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
	"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
	"{!Patient_Insurance__c.CoPay_Amount__c}"==""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
	"{!Patient_Insurance__c.Deductable__c}"== ""||
	"{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
	"{!Patient_Insurance__c.OOP_Max__c}"==""||
	"{!Patient_Insurance__c.OOP_Met__c}"== ""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"=="")
	{
	alert('Please populate insurance and limit fields before procedding...');
	}
	else
	{
     window.location.href = '/500/e?cas4={!Patient_Insurance__c.Patient__c}&00Nc0000001BVbO={!Patient_Insurance__c.Name}&retURL=%2F500%2Fo&RecordType=012c00000000aXZ&ent=Case';
	}
	
}
else
{
alert('The health plan category must be equal to Commercial.');
}
Thanks
Anil.B

All Answers

@anilbathula@@anilbathula@
Hi Ken Sfdc,

Try this code.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
if("{!Patient_Insurance__c.Health_Plan_Category__c}"=="Commercial")
{
	if("{!Patient_Insurance__c.Health_Plan__c}"==""||
        "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
	"{!Patient_Insurance__c.Payor__c}"==""||
	"{!Patient_Insurance__c.CoPay_Amount__c}"==""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"==""||
	"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
	"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
	"{!Patient_Insurance__c.CoPay_Amount__c}"==""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
	"{!Patient_Insurance__c.Deductable__c}"== ""||
	"{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
	"{!Patient_Insurance__c.OOP_Max__c}"==""||
	"{!Patient_Insurance__c.OOP_Met__c}"== ""||
	"{!Patient_Insurance__c.Coinsurance_Percent__c}"=="")
	{
	alert('Please populate insurance and limit fields before procedding...');
	}
	else
	{
     window.location.href = '/500/e?cas4={!Patient_Insurance__c.Patient__c}&00Nc0000001BVbO={!Patient_Insurance__c.Name}&retURL=%2F500%2Fo&RecordType=012c00000000aXZ&ent=Case';
	}
	
}
else
{
alert('The health plan category must be equal to Commercial.');
}
Thanks
Anil.B
This was selected as the best answer
Ken sfdc1Ken sfdc1
Anil,

Great it is working!!

But there is a condition change either copay Amount set of fields filled we have to allow or coinsurance set of field then we need to allow.

if("{!Patient_Insurance__c.Health_Plan__c}"==""||
        "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
"{!Patient_Insurance__c.Payor__c}"==""||
"{!Patient_Insurance__c.CoPay_Amount__c}"==""||
"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
"{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
"{!Patient_Insurance__c.Deductable__c}"== ""||
"{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
"{!Patient_Insurance__c.OOP_Max__c}"==""||
"{!Patient_Insurance__c.OOP_Met__c}"== ""||

else if

"{!Patient_Insurance__c.Coinsurance_Percent__c}"=="")
"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
"{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
"{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
"{!Patient_Insurance__c.Deductable__c}"== ""||
"{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
"{!Patient_Insurance__c.OOP_Max__c}"==""||
"{!Patient_Insurance__c.OOP_Met__c}"== ""||
"{!Patient_Insurance__c.Health_Plan__c}"==""||
 "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
"{!Patient_Insurance__c.Payor__c}"==""||

CAn you format wit one more if condition?

@anilbathula@@anilbathula@
Hi ,

Try this and modified code  and when "if" condition is failed  to satisfy then only it goes to "else if" so check your conditions for both .

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
if("{!Patient_Insurance__c.Health_Plan_Category__c}"=="Commercial")
{
	if("{!Patient_Insurance__c.Health_Plan__c}"==""||
        "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
        "{!Patient_Insurance__c.Payor__c}"==""||
        "{!Patient_Insurance__c.CoPay_Amount__c}"==""||
        "{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
        "{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
        "{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
        "{!Patient_Insurance__c.Deductable__c}"== ""||
        "{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
        "{!Patient_Insurance__c.OOP_Max__c}"==""||
        "{!Patient_Insurance__c.OOP_Met__c}"== "")	
	{
	alert('Please populate insurance and limit fields before procedding...');
	} 
	else if("{!Patient_Insurance__c.Coinsurance_Percent__c}"=="")
           "{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}"==""||
           "{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}"==""||
           "{!Patient_Insurance__c.Coinsurance_Percent__c}"== ""||
           "{!Patient_Insurance__c.Deductable__c}"== ""||
           "{!Patient_Insurance__c.Deductible_Amount_Met__c}"== ""||
           "{!Patient_Insurance__c.OOP_Max__c}"==""||
           "{!Patient_Insurance__c.OOP_Met__c}"== ""||
           "{!Patient_Insurance__c.Health_Plan__c}"==""||
           "{!Patient_Insurance__c.Health_Plan_Group_Number__c}"==""||
           "{!Patient_Insurance__c.Payor__c}"==""){
	alert('Please populate co-insurance fields before procedding...');		
		
	}
	else
	{
     window.location.href = '/500/e?cas4={!Patient_Insurance__c.Patient__c}&00Nc0000001BVbO={!Patient_Insurance__c.Name}&retURL=%2F500%2Fo&RecordType=012c00000000aXZ&ent=Case';
	}
	
}
else
{
alert('The health plan category must be equal to Commercial.');
}

Thanks
Anil.B
Raja JammulaRaja Jammula
Javascript: I am getting Unexpected token error for below code can you please help:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var obj;
var task5;
var recordtypeid;
var followup;
var recordtypefol;
if("{!$Profile.Name}" == "TX1" || 
"{!$Profile.Name}"== "TX2"||
"{!$Profile.Name}"== "WX1"||
"{!$Profile.Name}"== "WX2"||
"{!$Profile.Name}"== "WX3"||
"{!$Profile.Name}"== "WX4"|| 
"{!$Profile.Name}" == "CC"){

obj='a1r';
}
else{
obj='00T';
}
alert(obj);

var url='/'+obj+'/e?CF00N50000002CzJi={!Account.Name}&CF00N50000002CzJi_lkid={!Account.Id}&retURL=/{!Contact.Id}&title=Call&who_id={!Contact.Id}&00N50000002D0zP={!User.Primary_Product__c}'
if(obj=="a1r")
{
url+='&followup=1&tsk5=call'
}

if(obj=="00T"){
if("{!$Profile.Name}" == "WI" && ("{!$UserRole.Name}"=="AS - E"||"{!$UserRole.Name}"=="AS - M"||"{!$UserRole.Name}"=="AS - T")){
task5="Meeting";
recordtypeid="0123B0000008tqK";
followup='';
recordtypefol="0123B0000008tqK";
}elseif("{!$Profile.Name}" == "WI Corporate Sales") {
task5="call";
recordtypeid="01250000000HiDD";
followup ="1";
recordtypefol="01250000000HiDD"; 
}else{
url+='&tsk5='+task5+'$tsk12=Completed'+'&RecordType='+recordtypeid+'&RecordType_fu='+recordtypefol+'&followup='+followup+'&tsk4={!TODAY()}'
}
}
else{
url+='&followup=1&tsk5=call'
}

window.parent.open(url, "_self");