on 2020 Oct 13 9:56 PM
Hello.
I'm struggling to implement an Action inside CAP.
What I want to do is simple SELECT, but it throws me an error...
Service definition
using { demo.callcenter as call } from '../db/schema';
service CallCenterService {
entity Inquiries as select from call.Inquiries
actions {
@sap.applicable.path: 'startEnabled'
action start();
};
}
Service implementation
const cds = require('@sap/cds')
module.exports = async function () {
const { Inquiries } = cds.entities
this.on ('start', async (req)=> {
console.log('data: ' + req.data)
const id = req.params[0]
//Get createdAt
const createdAt = await SELECT.from(Inquiries).columns(['createdAt']).where({ID:id})
//Calculate hoursBeforeStart
const startedAt = Date.now()
const difference = startedAt - new Date(createdAt).getTime()
const hoursBefoerStart = Math.floor(difference/1000/60/60)
const n = await UPDATE(Inquiries).set({
status_code:'2',
startedAt: Date.now(),
hoursBefoerStart: hoursBefoerStart
}).where ({ID:id}).and({status_code:'1'})
n > 0 || req.error (404)
})
}
The error is occurring at below statement.
const createdAt = await SELECT.from(Inquiries).columns(['createdAt']).where({ID:id})
Can anybody point out what's wrong with this statement?
Thanks,
Mio
It was my namespace that was causing the issue: demo.callcenter.
ensureUnlocalized method compares the localized table name with below localized prefixes.
localized.de, localize.fr ....
In my case, localized table name is localized.demo.callcenter.Inquiries and it matches with localized.de, so the method truncates the table name, resulting the error.
I changed the namespace to zdemo.callcenter and now it is working fine.
It seems we cannot use namespaces starting with 'de', 'fr', or any other language keys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Title: ErroreMessage: Non è stato possibile aprire l’app perché il componente SAP UI5 dell’applicazione non è stato caricato.Details: {"info": "Il componente UI5 non è stato caricato per l’intento \"#Action-toappstateformsample\"","technicalMessage": "failed to load 'sap/ushell/demo/AppStateFormSample/Component.js' from ../../../../../test-resources/sap/ushell/demoapps/AppStateFormSample/Component.js: 404 - Not Found\nError: failed to load 'sap/ushell/demo/AppStateFormSample/Component.js' from ../../../../../test-resources/sap/ushell/demoapps/AppStateFormSample/Component.js: 404 - Not Found\n at makeNestedError (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:94:37)\n at requireModule (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:102:2782)\n at requireAll (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:104:527)\n at Object.r [as require] (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:109:597)\n at https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n at new Promise (<anonymous>)\n at https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919\nCaused by: Error: 404 - Not Found\n at a (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:88)\n at XMLHttpRequest.<anonymous> (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:321)\n at loadSyncXHR (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:98:415)\n at requireModule (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:102:2737)\n at requireAll (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:104:527)\n at Object.r [as require] (https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:109:597)\n at https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6952\n at new Promise (<anonymous>)\n at https://sapui5.hana.ondemand.com/1.78.6/resources/sap-ui-core.js:671:6919"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
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.