I've created a custom button called Commit and I'm trying to call the following method using action = {!.commit},

Apex below

Unexpected token: commit line 113

Do I need to do anything else to be able to call commit in my VF?

  • After removing dot.. still getting error... – Ratan Paul Mar 10 '16 at 9:34
  • Not sure why my previous comment was deleted, {!.commit} was a typo. I'm getting an Compile error on Line 113 after PageReference – Nikz_Kool Mar 10 '16 at 9:37
  • Can you post more code here? – Oles Malkov Mar 10 '16 at 9:47
  • Error Error: BPSection Compile Error: The method void save() is referenced by Visualforce Page (BrokerProfileSection) in salesforce.com. Remove the usage and try again. at line 113 column 17 - That's the new error. I've removed all reference to the save(), thanks @ Keith C – Nikz_Kool Mar 10 '16 at 9:59

The problem is probably that "commit" is a reserved word in Apex so you can't use it as a method or variable name. (When the compiler encounters such a word it has special meaning, it's part of the language.) Use a different name in the code and in the Visualforce.

Apex has a lot of these - see Reserved Keywords.

  • This really great to know.. Keith C.. have you used this keyword some where. I never used this. I am just wondering where salesforce used this keyword. – Ratan Paul Mar 10 '16 at 10:14
  • @Ratan No I haven't; I think they just reserved the word in case they ever wanted to introduce the concept in the future. – Keith C Mar 10 '16 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.