Skip to main content

Invoke a Class Method: invoke_classmethod()

Invoke a Class Method: invoke_classmethod()

A method is an executable element defined by a class. Caché supports two types of methods: instance methods (keyword Method) and class methods (keyword ClassMethod). An instance method is invoked from a specific instance of a class and typically performs some action related to that instance. A class method is a method that can be invoked without reference to any instance; these are called static methods in other languages. The term method usually refers to an instance method. The more specific phrase class method is used to refer to class methods.

Synchronous:

   var result = mydata.invoke_classmethod(class_method);

Asynchronous:

   mydata.invoke_classmethod(class_method, function(error, result){});
Example:
   var result = mydata.invoke_classmethod(
      {class: "User.customer",
       method: "MyClassMethod",
       arguments: [7]}
   );

result:

   {
      "ok": 1,
      "class": "User.customer",
      "method": "MyClassMethod",
      "arguments": ["7"],
      "result": "14"
   }
FeedbackOpens in a new tab