+ Start a Discussion

External ID and Apex.

Hi All,


Below given is my code and I am just trying to make my concept clear.I rran a small example using anonymous block but it is giving me some error.


I have created class and function in which I am upserting an opportunity based on the  external id which I am passing to the the called functiuon of the class named test with teh string parameter and in the class i am assigning this to the external id field and then uosetting opporunity using the external id field.However,it gives and error which is given below at the end of the code.Can somebody pleease help? 


public class TestClass
   string m;     
public void test(string number1)
    System.debug('The value in the variable of type m is'+m);
        opportunity opp=new opportunity(name='straw');
        System.debug('The value passed to the field External_Id1__c is'+opp.External_Id1__c);
               upsert opp External_Id1__c;  
        catch (DmlException e)

TestClass t=new TestClass();

line 2, column 1: Method does not exist or incorrect signature: [TestClass].test(String)







is this class enabled to current user's profile?
Neha LundNeha Lund

Please change the method NAme to some other name, since Test is a default keyword.. try this and post the results for the same.

i tried the same code and working fine for me.....I think if you place the class name as Test then that would be a problem but not as method name i think so....

Just check the method test from where it is referred(may be from another class) and from there send a string like this

"public void test(string number1)"


It may be because of the signature is not matching i.e correct argument is not passing.


If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.