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
trick1trick1 

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)
{
    m=number1;
    System.debug('The value in the variable of type m is'+m);
        opportunity opp=new opportunity(name='straw');
        opp.External_Id1__c=m;
        System.debug('The value passed to the field External_Id1__c is'+opp.External_Id1__c);
        try
        {
               upsert opp External_Id1__c;  
            
        }
        catch (DmlException e)
        {
            
                System.debug(e.getMessage());
            
        }
    
    }
}



TestClass t=new TestClass();
t.test('chris');


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

 

 

 

 

 

 

kiranmutturukiranmutturu
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.

kiranmutturukiranmutturu
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....
souvik9086souvik9086

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.

Thanks