+ Start a Discussion
Stavros McGillicuddyStavros McGillicuddy 

Delete query runs from Developer Console, Unexpected Identifier error from button

Why can I get this to run in the Developer Console but not from a custom button?
I get an unexpected identifier error 

OpportunityLineItem opp=[Select OpportunityID From OpportunityLineItem WHERE OpportunityId = '0063300000iu2IC'];
delete opp;

Ankit SehgalAnkit Sehgal
Your syntax of executing soql query is wrong.

use var opp=sforce.connection.query("Select  .. from...");

refer this link: https://developer.salesforce.com/docs/atlas.en-us.ajax.meta/ajax/sforce_api_ajax_more_samples.htm