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
KarenCKarenC 

Simple Apex Trigger - unexpected token???

Hi - 

 

I am writing a basic apex trigger to update a quote revision number.  I need to select the max version number within a quote, within an opportunity.

 

I get an unexpected token on the red line below.  The revision? field is a custom checkbox field in the quote table.

 

Thanks for your help!!!

 

 

 

trigger quoteversioning on Quote (before insert) {
for (quote insertedquote : system.Trigger.new)   

  {   

 

   if (insertedquote.revision?)

      {      quote QT = [select max(version__c) from quote

                        where quotenumber = :insertedquote.quotenumber                       

                        and opportunity = :insertedquote.opportunity];

 

               insertedquote.version__C = QT.version__c + 1;     

     }   

  }

}


Best Answer chosen by Admin (Salesforce Developers) 
apex_keenapex_keen

Since 'revision?' is custom field , please refer its API name,  it should be appended with '__c' at end.

All Answers

apex_keenapex_keen

Since 'revision?' is custom field , please refer its API name,  it should be appended with '__c' at end.

This was selected as the best answer
KarenCKarenC

Thanks!  That was a complete oversight.

 

Now it is telling me that opportunity is not a field in the quote table....hmmmm....I see it there?!

 

Would you happen to know how to find the correct opportunity from within a quote trigger?

 

Thanks again!!