<?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: Draft UPDATE is updating readonly f... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13925042#M4890694</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/181029"&gt;@patricebender&lt;/a&gt;&amp;nbsp;, by the setup I think &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1389897"&gt;@shf&lt;/a&gt;&amp;nbsp;&amp;nbsp;maybe refers to &lt;A href="https://cap.cloud.sap/docs/cds/cdl#calculated-elements" target="_self"&gt;Calculated Elements&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 13:27:17 GMT</pubDate>
    <dc:creator>catano</dc:creator>
    <dc:date>2024-10-31T13:27:17Z</dc:date>
    <item>
      <title>CAP + Typescript: Draft UPDATE is updating readonly fields -- a bug?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaq-p/13921469</link>
      <description>&lt;P&gt;Hello CAP and Typescript experts,&lt;/P&gt;&lt;P&gt;I have defined an draft-enabled entity with additional computed fields as follows:&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;entity BaseSystemTypes : managed {
        @title: '{i18n&amp;gt;Paltr_SystemTypes_ID_label}'
    key ID       : types.SystemType;

        @title: '{i18n&amp;gt;Paltr_Common_Name}'
        @mandatory
        techName : types.TechnicalName;

        @title: '{i18n&amp;gt;Paltr_Common_title}'
        @mandatory
        title    : types.Title;

        @title: '{i18n&amp;gt;Paltr_Common_isUsable_label}'
        isUsable : Boolean default true;

        myComputedField: String = ('');
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Within the service SystemTypes as projection on BaseSystemTypes, I let calculate the field myComputedField after READ:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;srv.after('READ', SystemTypes, async (req) =&amp;gt; {
      if (!req) return;       
      
      ...       

      req.forEach((singleEntity: any) =&amp;gt; {
        singleEntity.myComputedField = 'Test';
      }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Fiori App, if I create a new draft instance or change one of the fields manually of an existing record, the draft cannot be saved because "Property myComputedField does not exist in myservice.SystemTypes". If I comment the singleEntity.myComputedField = 'Test', the changes on drafts are working.&lt;/P&gt;&lt;P&gt;If I check the database table BaseSystemTypes, I cannot find the calculated field and I can see the calculated field within the draft views and draft table regarding myService_BaseSystemTypes_drafts. This is correct as far as I know.&lt;/P&gt;&lt;P&gt;But getting an error during creation or updating a draft , is this a bug now inside the UI5 framework ? Or do I have to delete now the changes using the srv.on events for CREATE/UPDATE ? I assumed calculated fields are ignored during any updates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 17:10:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaq-p/13921469</guid>
      <dc:creator>shf</dc:creator>
      <dc:date>2024-10-28T17:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: CAP + Typescript: Draft UPDATE is updating readonly fields -- a bug?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13922431#M4890315</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;By the error it seems that the database is not updated for some reason, could you check that somehow?&lt;BR /&gt;I just generated the hana artifacts with &lt;FONT face="courier new,courier"&gt;cds build --for hana&lt;/FONT&gt; for such setup, and the places I see the On-Read calculated fields are: &lt;FONT face="courier new,courier"&gt;Service.Entity.hdbview, Service.Entity_draft.hdbtable&lt;/FONT&gt;.&lt;BR /&gt;Could you share plase how do you check the tables / data?&lt;BR /&gt;I tried to edit / save draft of the entity with the On-Read calculated field, and I get no error.&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 09:50:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13922431#M4890315</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2024-10-29T09:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: CAP + Typescript: Draft UPDATE is updating readonly f...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13924732#M4890638</link>
      <description>&lt;P&gt;In the cds model, a computed field looks like this:'&lt;/P&gt;&lt;P&gt;"foo": { "@Core.Computed": true, "value": { "val": "bar" } }&lt;/P&gt;&lt;P&gt;I'm not sure what you are trying to achieve but if you want to adapt the value of a computed field,&lt;BR /&gt;you'd need to manipulate the object properly: `&amp;lt;entity&amp;gt;.foo.value.val = 'YOUR VALUE'`&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 09:04:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13924732#M4890638</guid>
      <dc:creator>patricebender</dc:creator>
      <dc:date>2024-10-31T09:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: CAP + Typescript: Draft UPDATE is updating readonly f...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13925042#M4890694</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/181029"&gt;@patricebender&lt;/a&gt;&amp;nbsp;, by the setup I think &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1389897"&gt;@shf&lt;/a&gt;&amp;nbsp;&amp;nbsp;maybe refers to &lt;A href="https://cap.cloud.sap/docs/cds/cdl#calculated-elements" target="_self"&gt;Calculated Elements&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 13:27:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13925042#M4890694</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2024-10-31T13:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: CAP + Typescript: Draft UPDATE is updating readonly f...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13925044#M4890695</link>
      <description>&lt;P&gt;But I do agree that maybe what it needs to be considered is the use of a &lt;A href="https://cap.cloud.sap/docs/cds/cdl#virtual-elements" target="_self"&gt;Virtual Element.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 13:29:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-typescript-draft-update-is-updating-readonly-fields-a-bug/qaa-p/13925044#M4890695</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2024-10-31T13:29:51Z</dc:date>
    </item>
  </channel>
</rss>

