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
John BraunJohn Braun 

Cannot figure something simple out with Onclick Javascript button!

Hi everyone,

 

I keep getting an error with my onclick javascript button, "Unexpected identifier".

 

Would anyone mind taking a look at my syntax and letting me know what could be wrong? Thanks so much!!!!!!

 

if ( '{!Opportunity.Active__c}' == '') 

alert('In order to request a Quote, you must ensure that the fields, Active, Product Type, Current Phase, and Project Scope for Patheon are populated'); 

else if ('{!Opportunity.Rx_OTC__c}' == '') 
{alert('In order to request a Quote, you must ensure that the fields, Active, Product Type, Current Phase, and Project Scope for Patheon are populated'); 


else if ('{!Opportunity.Project_phase__c}' == '') 
{alert('In order to request a Quote, you must ensure that the fields, Active, Product Type, Current Phase, and Project Scope for Patheon are populated'); 


else if ('{!Opportunity.Description}' == '') 
{alert('In order to request a Quote, you must ensure that the fields, Active, Product Type, Current Phase, and Project Scope for Patheon are populated'); 


else 

window.location = "/0Q0/e?&oppid={!Opportunity.Id}&ent=Quote&Name="Placeholder - Do Not Edit" 
&00NA0000004pyaC=1&ent=Quote 
&RecordType={!Opportunity.Quote_Record_Type__c} 
&retURL=/{!Opportunity.Id}"; 
}

Best Answer chosen by Admin (Salesforce Developers) 
sguptasgupta
If you use chrome then ctrl+shift+J, use firebug for firefox, IE F12...

All Answers

sguptasgupta
I guess problem is in this statement near &Name="Placeholder - Do Not Edit" , change it to near &Name='Placeholder - Do Not Edit' or change double quotes to ' at the beginning and end of stmt:

window.location = "/0Q0/e?&oppid={!Opportunity.Id}&ent=Quote&Name="Placeholder - Do Not Edit"
&00NA0000004pyaC=1&ent=Quote
&RecordType={!Opportunity.Quote_Record_Type__c}
&retURL=/{!Opportunity.Id}";
sguptasgupta
Use Javascript debugger or alert statements to find the exact location of the problem in ur javascript.
John BraunJohn Braun

Hi sgupta, thank you for the response,

 

Unfortunately it doesn't look like the problem was with the quotes. I changed:

 

window.location = "/0Q0/e?&oppid={!Opportunity.Id}&ent=Quote&Name="Placeholder - Do Not Edit"
&00NA0000004pyaC=1&ent=Quote
&RecordType={!Opportunity.Quote_Record_Type__c}
&retURL=/{!Opportunity.Id}";

 

To this:

 

window.location = "/0Q0/e?&oppid={!Opportunity.Id}&ent=Quote&Name='Placeholder - Do Not Edit'
&00NA0000004pyaC=1&ent=Quote
&RecordType={!Opportunity.Quote_Record_Type__c}
&retURL=/{!Opportunity.Id}";

 

....and it still didn't work.

 

Where do you go to get the javascript debugger? Thanks for your help!

sguptasgupta
If you use chrome then ctrl+shift+J, use firebug for firefox, IE F12...
This was selected as the best answer
Dave Miller.ax1920Dave Miller.ax1920
Get rid of any quotes around that Placeholder - Do Not Edit text.
The & and = parsing should grab the Name value as you might want.