Hello,
I'm using CAP with typescript and I have defined a draft-enabled entity SystemKinds. Cds-Typer is installed and Typescript types will be generated and updated each time I change my entity definition.
If I send a GET request with SystemKinds , I can see all properties of entity SystemKinds plus the draft properties IsActiveEntity, HasActiveEntity,HasDraftEntity. On sqlite database, I also see the auto-generated tables AdminConfigServices_SystemKinds_drafts and the DRAFT_DraftAdministrativeData with its properties e.g. InProcessByUser. Both tables are linked via DraftUUID.
Now, I like to display InProcessByUser in Fiori Elements list report and the date of last modification. Therefore, I try to extend my entity with these two properties. I don't know how to get access to these properties inside a READ handler. In other words, how do I get access to these auto-generated tables ? The approach with SystemKind.drafts does not work as documented in Fiori Support | capire (cloud.sap). Typescript does not know SystemKind.drafts or SystemKinds.drafts. It is not available in the type definition in folder @CDS-models.
Here is my AdminConfiguration.ts:
import cds from '@sap/cds';
import { SystemKind, SystemKinds } from '#cds-models/AdminConfigurationService';
class AdminConfigurationService extends cds.ApplicationService {
/** Registering custom event handlers */
init() {
// extract entities
const { SystemKinds } = this.entities
// Extend draft information
this.after('READ', SystemKinds, async( response ) => {
// here, i like to extend response with the properties LastChangedByUser from DRAFT_DraftAdministrativeData
// and HasDraftEntity from AdminConfigurationService_SystemKinds_drafts
}
}​
Request clarification before answering.
Yes, you are right:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
I saw this git commit today on the cds-type package and felt this would be the relevant update for you.
The draft properties are added to the type definition.
https://github.com/cap-js/cds-typer/pull/354
Regards,
Arun K
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.