on 11-27-2022 11:48 AM
Hello CAP Friends,
the SAPUI5 documentation at Configuring Custom Actions that Create New Objects describes this behaviour of the UI:
"If a user triggers the action, note the following behavior in a draft application: if the back-end system returns a draft object as the result of the action, the front-end system automatically navigates to the object page where the new draft object is opened in edit mode."
This is exactly the behaviour I want to achieve. I've implemented an example in my bookshop-demo which can be tested via: http://localhost:4004/webapp/fiori-latest.html#V4Role-manageUI5latest. When you click there the action button "createDraftRole" you will be asked to enter the role name and description. When you then click the createDraftRole button of the pop-up the Entity is created using this code:
srv.on(["createDraftRole"], async (req) => {
const adminService = await cds.connect.to("AdminService");
const { Roles } = adminService.entities;
console.log("createDraftRole - Request Parameters:", req.data);
const insertRes = await cds.run(
INSERT.into(Roles).entries([
{
ID: cds.utils.uuid(),
rolename: req.data.rolename,
description: req.data.description,
},
])
);
const keyFields = [...insertRes][0];
delete keyFields.IsActiveEntity;
const roles = await cds.run(SELECT.from(Roles).where(keyFields));
const role = roles[0];
return role;
});
The UI navigates also the the created entity. But unfortuantely not in Edit mode. That due to the fact that I haven't found any documentation how to create a draft Entity in the CAP Node.JS documentation about Built-in Draft Support. It seems that for CAP Java this is already possible: Consuming Draft Services.
Would be great to know what is planned in this direction.
Best Regards
Gregor
Thanks gregorw !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.