<?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>topic Re: SAP CAP nodeJS .drafts undefined in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13952794#M2037998</link>
    <description>&lt;P&gt;THanks for your reply. It showed my the reason...&lt;/P&gt;&lt;P&gt;As we're using storyboard, which needs&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"@sap/low-code-event-handler"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"^1.2.4"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;my handler class is auto generated and the calls are delegated to a js file.&lt;/P&gt;&lt;P&gt;In those files I can't work with &lt;STRONG&gt;this&lt;/STRONG&gt;.entities&lt;STRONG&gt;.&lt;/STRONG&gt; So I need &lt;STRONG&gt;cds&lt;/STRONG&gt;.entities and for accessing it in that way I always get undefined for &amp;lt;Entity&amp;gt;.drafts&lt;/P&gt;&lt;P&gt;Any idea how to overcome this?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2024 06:57:37 GMT</pubDate>
    <dc:creator>T1mey</dc:creator>
    <dc:date>2024-12-02T06:57:37Z</dc:date>
    <item>
      <title>SAP CAP nodeJS .drafts undefined</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13951856#M2037993</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;all my SELECT's of .drafts entities are failing as .dafts is undefined.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="T1mey_0-1732885842495.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/196818iC25BD3CD7E1F2CC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="T1mey_0-1732885842495.png" alt="T1mey_0-1732885842495.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;working with sap/cds 8.5.0.&lt;/P&gt;&lt;P&gt;Anybody else the problem. Using a string representation works... but is ugly &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 13:12:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13951856#M2037993</guid>
      <dc:creator>T1mey</dc:creator>
      <dc:date>2024-11-29T13:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CAP nodeJS .drafts undefined</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13952313#M2037996</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/339928"&gt;@T1mey&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Have you thought about providing more information and/or code example on how your model, service and the SELECT statement looks like? In my experience, in most of the cases this may speed up the process of finding out what the exact case is.&lt;/P&gt;&lt;P&gt;I&lt;SPAN&gt;&amp;nbsp;tried with &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;"@sap/cds"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"^8.5.0" &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;in the following ways, both worked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;service implementation variants:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;class MyService extends cds.ApplicationService {
  init() {
    const { MyServiceEntity } = this.entities;

    (async () =&amp;gt; {
      const res = await SELECT.from(MyServiceEntity.drafts);
    })();

    this.on('READ', MyServiceEntity, async (req) =&amp;gt; {

      await SELECT.from(MyServiceEntity.drafts);

    });&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;module.exports = cds.service.impl(async function (srv) {
  
  const { MyServiceEntity } = this.entities;

  (async () =&amp;gt; {
    const res = await SELECT.from(MyServiceEntity.drafts);
  })();

  srv.on('READ', MyServiceEntity, async (req) =&amp;gt; {

    await SELECT.from(MyServiceEntity.drafts);

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;service.cds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;using { my.namespace as db } from '../db/schema';

service MyService {
    entity MyServiceEntity as projection on db.MyDbEntity;
}

annotate MyService.MyServiceEntity with @odata.draft.enabled;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;db.schema&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;entity MyDbEntity {
  key ID: Integer;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Peter&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2024 13:22:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13952313#M2037996</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2024-11-30T13:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CAP nodeJS .drafts undefined</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13952794#M2037998</link>
      <description>&lt;P&gt;THanks for your reply. It showed my the reason...&lt;/P&gt;&lt;P&gt;As we're using storyboard, which needs&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"@sap/low-code-event-handler"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"^1.2.4"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;my handler class is auto generated and the calls are delegated to a js file.&lt;/P&gt;&lt;P&gt;In those files I can't work with &lt;STRONG&gt;this&lt;/STRONG&gt;.entities&lt;STRONG&gt;.&lt;/STRONG&gt; So I need &lt;STRONG&gt;cds&lt;/STRONG&gt;.entities and for accessing it in that way I always get undefined for &amp;lt;Entity&amp;gt;.drafts&lt;/P&gt;&lt;P&gt;Any idea how to overcome this?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 06:57:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13952794#M2037998</guid>
      <dc:creator>T1mey</dc:creator>
      <dc:date>2024-12-02T06:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CAP nodeJS .drafts undefined</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13953957#M2038006</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/339928"&gt;@T1mey&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see no options to access service entities through &lt;FONT face="courier new,courier"&gt;cds&lt;/FONT&gt; unfortunately.&lt;BR /&gt;One can only access db entities, but there is no drafts in that layer.&lt;/P&gt;&lt;P&gt;Maybe if somehow you can access the service module in your delegate, and use &lt;FONT face="courier new,courier"&gt;serviceModule.entites&lt;/FONT&gt;?&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Peter&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 08:49:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cap-nodejs-drafts-undefined/m-p/13953957#M2038006</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2024-12-03T08:49:32Z</dc:date>
    </item>
  </channel>
</rss>

