<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: CAP typescript: how do I get draft data from draft en... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13904936#M4888948</link>
    <description>&lt;P&gt;Yes, you are right:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;draftData&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;await&lt;/SPAN&gt; &lt;SPAN&gt;SELECT&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SystemKinds&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;drafts&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;is giving me all properties of my entity SystemKinds plus property "HasActiveEntity" and "DraftAdministrativeData_draftUUID" of table&amp;nbsp;&lt;SPAN&gt;AdminConfigServices_SystemKinds_drafts but not the properties "HasDraftEntity" and "IsActiveEntity"&lt;/SPAN&gt;. But this is ok and sufficiently.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I was confused because of getting error messages in VSCODE around "SystemKinds.drafts" (red underlined) . If I hover over "SystemKinds.drafts", I will get typescript error, but I get no program dumps. Thus, I thought if typescript has an issue, the program will crash...&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But I'm still missing typescript type definition for SystemKinds.drafts in one of the .ts files in the&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1434188"&gt;@CDS&lt;/a&gt;-models folder.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yours,&lt;/DIV&gt;&lt;DIV&gt;Stephan&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 19 Oct 2024 16:18:46 GMT</pubDate>
    <dc:creator>shf</dc:creator>
    <dc:date>2024-10-19T16:18:46Z</dc:date>
    <item>
      <title>CAP typescript: how do I get draft data from draft enabled entity?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaq-p/13904554</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;A href="https://cap.cloud.sap/docs/node.js/fiori#differences-to-previous-version" target="_blank" rel="noopener"&gt;Fiori Support | capire (cloud.sap)&lt;/A&gt;. Typescript does not know SystemKind.drafts or SystemKinds.drafts. It is not available in the type definition in folder&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1434188"&gt;@CDS&lt;/a&gt;-models.&lt;/P&gt;&lt;P&gt;Here is my AdminConfiguration.ts:&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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 ) =&amp;gt; { 
     // here, i like to extend response with the properties LastChangedByUser from DRAFT_DraftAdministrativeData
    // and HasDraftEntity from AdminConfigurationService_SystemKinds_drafts
    }
}​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Does anyone know how I can read draft-related administrative data?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Yours&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Stephan&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Oct 2024 19:47:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaq-p/13904554</guid>
      <dc:creator>shf</dc:creator>
      <dc:date>2024-10-18T19:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft enabled entity?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13904825#M4888940</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do you get when reading the draft entities.&amp;nbsp;&lt;/P&gt;&lt;P&gt;const draftData = await SELECT.from(SystemKinds.drafts).where({..where condition });&lt;BR /&gt;Does this select not give you the draft adminsitrative data?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Oct 2024 11:28:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13904825#M4888940</guid>
      <dc:creator>arunkrishnamoorthy1988</dc:creator>
      <dc:date>2024-10-19T11:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft en...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13904936#M4888948</link>
      <description>&lt;P&gt;Yes, you are right:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;draftData&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;await&lt;/SPAN&gt; &lt;SPAN&gt;SELECT&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SystemKinds&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;drafts&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;is giving me all properties of my entity SystemKinds plus property "HasActiveEntity" and "DraftAdministrativeData_draftUUID" of table&amp;nbsp;&lt;SPAN&gt;AdminConfigServices_SystemKinds_drafts but not the properties "HasDraftEntity" and "IsActiveEntity"&lt;/SPAN&gt;. But this is ok and sufficiently.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I was confused because of getting error messages in VSCODE around "SystemKinds.drafts" (red underlined) . If I hover over "SystemKinds.drafts", I will get typescript error, but I get no program dumps. Thus, I thought if typescript has an issue, the program will crash...&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But I'm still missing typescript type definition for SystemKinds.drafts in one of the .ts files in the&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1434188"&gt;@CDS&lt;/a&gt;-models folder.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yours,&lt;/DIV&gt;&lt;DIV&gt;Stephan&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 19 Oct 2024 16:18:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13904936#M4888948</guid>
      <dc:creator>shf</dc:creator>
      <dc:date>2024-10-19T16:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft enabled entity?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13915047#M4889244</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;does your project happen to be built with cds8? If so, did you install&amp;nbsp;&lt;A href="https://www.npmjs.com/package/@cap-js/cds-types" target="_blank"&gt;@cap-js/cds-types&lt;/A&gt; as devDependency?&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 06:57:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13915047#M4889244</guid>
      <dc:creator>daniel_ogrady65</dc:creator>
      <dc:date>2024-10-22T06:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft en...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13919779#M4889938</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;my packag.json encounters the following:&lt;/P&gt;&lt;LI-CODE lang="json"&gt; "devDependencies": {
        "@cap-js/cds-typer": "&amp;gt;=0.1",
        "@cap-js/cds-types": "^0.6",
        "@cap-js/sqlite": "^1",
        "@sap/ux-specification": "UI5-1.129",
        "@types/node": "^20",
        "@sapui5/types": "^1.116",
        "@ui5/cli": "^4.0.8",
        "typescript": "^5"
    
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I do the following, I will get the DraftAdministrativeData as follows:&lt;/P&gt;&lt;P&gt;let AvailEntities: cds.entity[] = [SystemKinds, SystemKinds.drafts];&lt;BR /&gt;srv.after('READ', AvailEntities, async (response) =&amp;gt; {&lt;BR /&gt;if (!response) return;&lt;BR /&gt;....&lt;BR /&gt;const currentUser = cds.context?.user.id;&lt;BR /&gt;.....&lt;BR /&gt;response.forEach((singleEntity: any) =&amp;gt; {&lt;BR /&gt;....&lt;BR /&gt;let IsCreatedByMe : Boolean = singleEntity.DraftAdministrativeData.DraftIsCreatedByMe;&lt;BR /&gt;let InProcessBy : String = singleEntity.DraftAdministrativeData.InProcessByUser;&lt;BR /&gt;});&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;For the SystemKinds.drafts , there is no TypeScript type auto-generated. The draft administrative data can be accessed by the entity's DraftAdministrativeData property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 15:43:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13919779#M4889938</guid>
      <dc:creator>shf</dc:creator>
      <dc:date>2024-10-25T15:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft en...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13920405#M4890024</link>
      <description>&lt;P&gt;Hi Stephen,&lt;/P&gt;&lt;P&gt;I saw this git commit today on the cds-type package and felt this would be the relevant update for you.&lt;/P&gt;&lt;P&gt;The draft properties are added to the type definition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/cap-js/cds-typer/pull/354" target="_blank"&gt;https://github.com/cap-js/cds-typer/pull/354&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Arun K&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2024 12:02:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13920405#M4890024</guid>
      <dc:creator>arunkrishnamoorthy1988</dc:creator>
      <dc:date>2024-10-27T12:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: CAP typescript: how do I get draft data from draft en...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13920484#M4890038</link>
      <description>Hi Arun, I have updated NPM with the newest version of &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1434188"&gt;@CDS&lt;/a&gt;-typer . There are not all properties available: InProcessByUser is missing.</description>
      <pubDate>Sun, 27 Oct 2024 16:24:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-how-do-i-get-draft-data-from-draft-enabled-entity/qaa-p/13920484#M4890038</guid>
      <dc:creator>shf</dc:creator>
      <dc:date>2024-10-27T16:24:44Z</dc:date>
    </item>
  </channel>
</rss>

