invoke

Invokes an object method and returns the result of the invoked method.

invoke(instance, methodName [, arguments]) → returns any

invoke Argument Reference

instance string
Required

Name or instance of a CFC or an instance of a Java, .NET, COM or CORBA object

methodname string
Required

The name of the method to invoke.

arguments any

An array of positional arguments or a struct of named arguments to pass into the method.

Examples sample code invoking the invoke function

Invokes the size method on a new HashMap object, which should return 0

invoke(createObject("java", "java.util.HashMap"), "size")

Expected Result: 0

Invokes the method named 'test' on the component Test.cfc with one parameter

obj = createObject("component", "Test");
invoke(obj, "test", {parameter="Test Data"});

Invokes the method named 'test' on the webservice Test.cfc with one argument

obj = createObject("webservice", "https://example.com/test.cfc?wsdl");
invoke(obj, "test", {argument1="Test Data"});

Invokes the method named 'test' on the webservice Test.cfc with multiple arguments

obj = createObject("webservice", "https://example.com/test.cfc?wsdl");
invoke(obj, "test", {argument1="Test Data", argument2="More Data", argument3="Still More Data"});

Fork me on GitHub