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
EmsegalEmsegal 

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;
    en='Segal';
    gCode=LEFT(en,2);
  }

 

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?

 

Thanks.

 

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

McFitz13McFitz13

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

gitguygitguy

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

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm

 

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)