on 04-09-2021 12:52 PM
Hello,
I am trying to learn CAP and Fiori Elements. I have created the simplest service.
db/schema.csd
namespace db;
entity Todos {
key Id: Integer;
description: String;
completed: Boolean;
}
And I have loaded some mock data (db/data/db-Todos.csv)
Id;description;completed
101;Shopping for groceries;false
102;Walk the dog;true
103;Clean up the garage;fale
I have created the service (srv/service.cds)
using {db} from '../db/schema';
service TodoService {
entity Todos as projection on db.Todos;
}
annotate TodoService.Todos with @(
UI: {
HeaderInfo : {
$Type : 'UI.HeaderInfoType',
TypeName : 'Todo',
TypeNamePlural : 'Todos',
},
SelectionFields : [
completed
],
LineItem : [
{ Value: Id, Label: 'Id' },
{ Value: description, Label: 'Description' },
{ Value: completed, Label: 'Completed' }
],
}
);
When I do "cds watch" it works fine, I can both get the odata and do the "preview fiori"
Then I have created the "srv/service.js" to implement the handler "on" and return a json
const cds = require('@sap/cds')
module.exports = cds.service.impl (function(){
this.on('READ','Todos', ()=>{
const data = [
{
"Id": 101,
"description": "Shopping for groceries",
"completed": false
},
{
"Id": 999,
"description": "Walk the dog",
"completed": true
},
{
"Id": 103,
"description": "Clean up the garage",
"completed": true
}
]
return data
})
})
now I can still get the odata, but the fiori preview is not working any more
I don't understand why the fiori preview is not working. The json returned by the Odata service looks exactly the same.
Anybody knows why is this happening?
Please check the network traffic when using the standard app without the custom implementation. You will see that it requests also count how many entries are contained in the entity. Check how I solved it in srv/customer-material-service.js#L66.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.