+ Start a Discussion

Newbie question: Method does not exist or incorrect signature:

I am getting the above error message on a trigger. I have stripped the trigger way way down to make it easier to diagnose the problem.


Here is the complete trigger



trigger tryi on Contact (before update) {
    string gCode;
    string en;


and here is the complete error:

Error: Compile Error: Method does not exist or incorrect signature: LEFT(String, Integer) at line 5 column 11


But I know that LEFT exists, and I know that 'Segal' is a string, and I know that 2 is an integer. So what am I missing?




Best Answer chosen by Admin (Salesforce Developers) 

All Answers


I clicked on the accepted solution button thinking that I could not accept a solution for someone else but I guess you can...sorry about that.


...but yes, you will have to use a function within the string class.


Good Answer @kpeters

Tom G.ax970Tom G.ax970

The odd thing is, there's supposed to be a left() method on strings.  It's in the documentation




But, the example in the documention doesn't work!


String s1 = 'abcdaacd';
String s2 = s1.left(3);
System.assertEquals('abc', s2);

Inside execute anonymous returns: 

Compile error at line 2 column 13
Method does not exist or incorrect signature: [String].left(Integer)