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
Adelchi PelizzoAdelchi Pelizzo 

Method does not exist or incorrect signature: createData()

I have this small piece of code here:
public class CreateDataFiscCode {
    public Contact createData(){
        Contact contact = new Contact
            (
                FirstName = 'Paolo',
    			LastName = 'Polio',
        		Birthdate = date.parse('12/12/1912'),
        		Birthplace__c = 'Attimis',
        		Provincia__c = 'UD',
        		Sesso__c = 'M'
        	);
        insert contact;
        return contact;
    }
}

I do not understand why when I execute anonymously just the mothod <createData()> I get the above error: Method does not exist or incorrect signature
Best Answer chosen by Adelchi Pelizzo
Hargobind_SinghHargobind_Singh
Hi, 

Am not sure how you are calling in your anonymous block, but this should work:
 
CreateDataFiscCode  cls = new CreateDataFiscCode (); 
cls.createData();

Alternatively, you can declare the createData function as static to call it directly without instantiating the class variable. 


===
If your problem/query is resolved, please mark your post as "Solved" so that community can benefit from resolved posts.