You need to sign in to do that
Don't have an account?
b.gonzalez
OnClick JavaSCript for this button encountered. Unexpected toekn ILLEGAL
A problem with the OnClick JavaSCript for this button or link was encountered. Unexpected toekn ILLEGAL. Not sure what is "illegal".
PLEASE HELP!
Beth
PLEASE HELP!
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")} if('{!Opportunity.Opportunity_Status__c}' == 'Denied') { alert('This opportunity cannot be approved because it has been denied.'); } else if('{!Opportunity.Opportunity_Status__c}' != 'Approved') { alert('This opportunity must be approved in order to complete this action.'); }else if('{!Opportunity.Amount}' != '0.00') { alert('This opportunity cannot be updated because no products are listed'); }else if('var strQuantity = sforce.connection.query("select Id, Quantity from opportunityLineItem where OpportunityId = '{!Opportunity.Id}'")'); }else if('var records = strQuantity.getArray("records")'); }else if('var quantity; for (var i=0; i< records.length; i++) { var record = records[i]; if (record.Quantity <50) { quantity = record.Quantity'); } } }else if('switch(true){ case quantity<50:'){ alert('Quantity on products cannot be less than 50.')); }else { sforce.apex.execute("CMR_DesignWebService", "UpdateToPMIDesign",{OpportunityId:'{!Opportunity.Id}'}); alert('Opportunity Approved in PMI system.'); window.location = window.location; }
Beth
I think I understand how it should work. Please try the updated snippet
In case this code returns an error could you please attach a screenshot?
All Answers
Actually, this snippet has a lot of syntax mistakes
line 10: trying to perform SOQL select in IF condition
line 11: trying to perform SOQL select in IF condition
line 12: trying to define a variable in IF condition
line 19: specifying SWITCH instead of IF condition
it should loks like
I modified the button to include a validation. This validation will not allow the user to "Update to PMI Design" if any of the products have a quantity less than 50. I took what you provided above and update my button in sandbox but I am still recieving the same error.
Beth
I think I understand how it should work. Please try the updated snippet
In case this code returns an error could you please attach a screenshot?
That worked. Thank you for your help. I appreciate it!
Beth