3

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?

4
  • After removing dot.. still getting error...
    – Ratan Paul
    Commented Mar 10, 2016 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
    Commented Mar 10, 2016 at 9:37
  • Can you post more code here? Commented Mar 10, 2016 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
    Commented Mar 10, 2016 at 9:59

1 Answer 1

9

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.

2
  • 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
    Commented Mar 10, 2016 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
    Commented Mar 10, 2016 at 11:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .