You need to sign in to do that
Don't have an account?
tarun jain 110
I want to access the function of first class in to another class but Error: Compile Error: Method must define a body
I want to access the function of first class in to another class
public with sharing class HelperClass {
public void helperMethod()
{
CustomObject__c acct = new CustomObject__c();
acct.Name = 'test';
insert acct;
}
}
public with sharing class MainClass {
private HelperClass helper = new HelperClass();
helper.helperMethod();
}
Please provide answer of above problem i want to do same thing as shown in above classes
Error: Compile Error: Method must define a body
public with sharing class HelperClass {
public void helperMethod()
{
CustomObject__c acct = new CustomObject__c();
acct.Name = 'test';
insert acct;
}
}
public with sharing class MainClass {
private HelperClass helper = new HelperClass();
helper.helperMethod();
}
Please provide answer of above problem i want to do same thing as shown in above classes
Error: Compile Error: Method must define a body
You can't call a method in the class.
You have to create a method or constructor in the class to invoke a method.
Like this:here I am using constructor.
Let me know if you have any issues.
Mark it as best answer if it helps.
Thanks.
Mark it as best answer if it helps.
Thanks.
Please update you class with this code Thanks
i hop it helps you
Please Mark it best answer if it helps you so it make proper solution for other:)
Facing issue of DML currently not allowed
are you using this class in vf page ?