on 01-23-2023 3:54 PM
Hello dear Community I need your help / advice
I have a Fiori Freestyle worklist App displaying a custom cds view in which I select mutiple entries and want to send the objects to my NodeJS Backend(FioriObj.js) in which the objects get combined and send to the mapping (mapping.js) function.
The Problem is: How do I properly import a normal NodeJS file in a UI5 Controller?
sap.ui.define([
'sap/m/MessageToast',
"./BaseController",
"sap/ui/model/json/JSONModel",
"../model/formatter",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"app/srv/FioriObj" <=== Path to class that needs to be accessed by the controller
], function (MessageToast,
BaseController,
JSONModel,
formatter,
Filter,
FilterOperator,
FioriObj) {
"use strict";
return BaseController.extend("app.controller.Worklist", {
.....
onUpdateSend: async function() {
var aSelectedProducts, i, sPath, oProductObject;
let messageArray = [];
aSelectedProducts = this.byId("table").getSelectedItems();
console.log(aSelectedProducts)
if (aSelectedProducts.length) {
for (i = 0; i < aSelectedProducts.length; i++) {
sPath = aSelectedProducts[i].getBindingContext().getPath();
oProductObject = aSelectedProducts[i].getBindingContext().getObject();
console.log(oProductObject);
messageArray.push(oProductObject.Supplier +" PO: "+ oProductObject.PurchaseOrder)
}
MessageToast.show("Selected: " + messageArray);
console.log("Message Toast log:" + messageArray)
let Send = await FioriObj.ObjectReceiver(oProductObject); <====== object that needs to be sent to a class outside of the controller
} else {
console.log("Error")
}
}
});
},true);
<br>
As shown in the picture, the given file gets found but despite not showing any errors in BAS, Chrome Console gives me errors for using import / require statements for the mapping.js as well as module.exorts.
Same for just the module.exports without any require / import:
Is there a way to send an object to your local backend and keep using regular NodeJs in that class / what do I need to change?
Thanks in advance for your advice & help ❤️
I would suggest you implement your backed using SAP Cloud Application Programming Model and then consume it via an OData Service call. Backend and Frontend can share JS libraries, but the communication must happen via HTTP(S).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would suggest the learning journey: Develop Applications Running on SAP BTP Using SAP HANA Cloud to get a more solid understanding.
they are all js, but they live in different world, you cannot do that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
65 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.