on 2024 Aug 07 12:02 AM
Hi fellow coders,
in SAP BTP BAS a CAP app is emerging beautifully helped by templates like the SAPUI5 worklist. The entity underneath that worklist has a key ID defined as integer, and a custom s_id, defined as a string. Anyway, for these two IDs, I have developed a counter that automatically creates new numbers for new instances of the object. On the object page these counters work properly.
The worklist has a Create button. When the user clicks it, they are getting a popup titled "Create" with an empty field, the object ID, apparently to be filled manually.
I'd like to skip that popup. How might I achieve that, given I had used the worklist template for my UI?
---
Here are a few screenshots to illustrate what I am dealing with:
Popup "Create".
Create button in worklist.
When leaving the ID field empty and continuing, the object detail screen shows, still without S-ID:
Object detail screen
Dummy entries for title, and text. Selection for Classification:
After "Create" the S-ID gets created.
I'd like to have the ID and S-ID created ideally upon pressing the Create button on the worklist, not after filling out the mandatory fields on the object details. How might I achieve that?
The blog_service.js code has the numbering routine, but apparently for the object details:
The easiest approach would be to let the framework handle ID generation by using a UUID instead of integer. You can still generate an 's_id' afterwards if you want a 'human readable ID' on top of the technical ID. See CAP documentation here: https://cap.cloud.sap/docs/guides/domain-modeling#primary-keys
To your scenario of using manual integer ID, the popup is required because your object gets created in draft before the user can add details and 'create' the object. When clicking that second 'create', the object is actually already created, so required an ID.
You can remove the popup and generate the ID by providing a default values function (NewAction), see here: https://ui5.sap.com/#/topic/11ff444f82e14eb3a2e8eca0065a5055. This NewAction should point to a bound action returning a created instance, e.g.:
this.on(Blogs.actions.getDefaultValues, async req => {
return await this.send({
//@ts-ignore
query: INSERT.into(Blogs).entries([{ID: 123}]),
event: "NEW"
})
})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.