[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: How to call a function in Openedge on oepas from Kendo javascript

Status
Not open for further replies.
E

egarcia

Guest
Hello, > What I would like to do is somehow call (openedge) code on the server with the order number that is selected. > This in turn, would generate a single PDF and send it to the client. Here is a link that describes the usage of invoke operations with the JSDO: community.progress.com/.../2938.calling-invoke-operations-with-the-jsdo From a Kendo UI Builder app, you would either create a new JSDO instance for the resource or use the JSDO instance associated with the Kendo UI DataSource in your view. The syntax to use access the DataSource depends on the view type. Here is how it would look from a custom view in a new function in controller.public.js: Here OrderOrderLineDS is the DataSource defined for the view. getMonthlySales(piYear, pcSalesRep) { var that = this; // var jsdo = new progress.data.JSDO({ name: "OrderOrderLine" }); 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."); }); } From a built-in view, the access to the DataSource would look like the following: var jsdo = this.$ds[this.$primeDSName].transport.jsdo; You can check controller.js to see how the DataSource is defined. The invoke method in the Business Entity would look like the following: @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. In your particular case, you might need to encode the PDF into a LONGCHAR so that it can be transferred via the parameters. If you are using a temp-table, please notice that the access to the values, as shown in function getMonthlySales(), would have the name of the temp-table (ttSales) twice, once to represent the name of the parameter and a 2nd time to represent the value of the temp-table structure. I hope this helps. It contains a method with the following structure: @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.

Continue reading...
 
Status
Not open for further replies.
Top