You need to sign in to do that
Don't have an account?

How to create function/method in Apex class
How can I create and call a function in an Apex class that will return a value? I have managed to create a void method that doesn't return, but I need to return a value.
Cheers
Cheers
To answer your question, I've included the following example:
public class foo {
string str_foo;
public string retfoo(String foo){
str_foo = 'method retfoo is returning this value: '+foo;
return str_foo;
}
}
--- you can invoke this through the following script:
foo f = new foo();
f.retfoo('I am returning something');
system.debug(f);