Invoke methods in Business Entities can be called using JSDO.invoke():

This functionality is also available from Kendo UI Builder.

You can call invoke methods by using a new JSDO instance or the JSDO instance associated with a DataSource used by your view in Kendo UI Builder.

Using a new JSDO instance

jsdo = new progress.data.JSDO('OrderOrderLine');
jsdo.invoke('<method-name', <parameters>).then( <success handler>, <error handler> );

Using the JSDO instance of the DataSource in a built-view 

The reference to a DataSource in a built-in has a different format based on the type of view. You can identify the actual reference by looking at the controller.public.js to see how it is created.

jsdo = this.$ds[this.$primeDSName].transport.jsdo;
jsdo.invoke('<method-name', <parameters>).then( <success handler>, <error handler> );

Using the JSDO instance of the DataSource in a custom view 

The reference to a DataSource in a custom view created using the blank template use the name that you specify in the configuration.

jsdo = this.$ds.OrderOrderLineDS.transport.jsdo;
jsdo.invoke('<method-name', <parameters>).then( <success handler>, <error handler> );

Calling the invoke operation

The code to call the invoke operation would look like the following:

getMonthlySales(piYear, pcSalesRep) {
      var that = this;
      // var jsdo = new progress.data.JSDO({ name: "OrderOrderLine" });
      // var jsdo = this.$ds[this.$primeDSName].transport.jsdo;
      var jsdo = this.$ds.OrderOrderLineDS.transport.jsdo;
 
      piYear = Math.trunc(piYear);
      jsdo.invoke("MonthlySales", { piYear: piYear, pcSalesRep: pcSalesRep })
          .then(function (jsdo, success, request) {
              console.log("Success: ", request.response.ttSales.ttSales);
              angular.element("#textbox0").val("");
              request.response.ttSales.ttSales.forEach(function (element) {
                  console.log(
                      "SalesRep: " + element.SalesRep
                      + " Month: " + element.Month
                      + " " + "Sales: " + element.Sales);
 
                  if (element.Month === 1) {
                      angular.element("#textbox0").val(element.Sales);
                  }
              });
          }, function () {
              console.log("Error while calling invoke operation.");
          });
  }

The method definition in the Business Entity would use annotations to indicate that it is an invoke method:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
@progress.service.resourceMapping(type="REST", operation="invoke", URI="/MonthlySales", alias="", mediaType="application/json").
METHOD PUBLIC VOID MonthlySales(INPUT piYear AS INTEGER, INPUT pcSalesRep AS CHARACTER, OUTPUT TABLE ttSales ):

...
END METHOD.

The method can be called from the JSDO once the catalog file is updated with the invoke operation.

Related Links

===