<?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; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257188#M4590508</link>
    <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;My bad again, sorry! It needs to be db.after not db.on, as you want to augment the result and not override the result fetching itself. I'll update my answer above.&lt;/P&gt;&lt;P&gt;BTW, The reason why your code is not called if using db.on is that the on phase is an interceptor stack and you'd need to &lt;A href="https://cap.cloud.sap/docs/node.js/api#srv-prepend" target="_blank"&gt;prepend&lt;/A&gt; your handler (db.on(...) appends).&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;</description>
    <pubDate>Mon, 05 Oct 2020 14:16:36 GMT</pubDate>
    <dc:creator>vansyckel</dc:creator>
    <dc:date>2020-10-05T14:16:36Z</dc:date>
    <item>
      <title>CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaq-p/12257178</link>
      <description>&lt;P&gt;Hallo Experts, I have an issue about READ handler.&lt;/P&gt;
  &lt;P&gt;I have an Entity with calculation fields. In order to set these fields, I have implemented READ handler.&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849508-yjaq3.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849511-b0bzp.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Triggering a GET request everythings is ok: fields are calculated.&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849510-vli12.png" /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849509-qbiln.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Triggering a PUT request in order to modify entity’s data, fields are empty.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849512-3m7s6.png" /&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849513-qm9ib.png" /&gt;&lt;/P&gt;
  &lt;P&gt;CAP after update runs _readAfterWrite function; this function re-loads entity’s data from DB correctly. After this function, CAP should trigger my READ handler, but it doesn’t.&lt;/P&gt;
  &lt;P&gt;As a result my calculated fields are empty.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849514-nbajx.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Any ideas on how to solve this problem?&lt;/P&gt;
  &lt;P&gt;Best regards.&lt;/P&gt;
  &lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 09:22:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaq-p/12257178</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-09-25T09:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257179#M4590499</link>
      <description>&lt;P&gt;you could try putting your code in after-READ, and see if it is triggered then. &lt;/P&gt;&lt;P&gt;Also, you could use same function _setDscriptions in after-UPDATE (same as in after-READ. note that after-READ and on-READ have different parameters)&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 09:36:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257179#M4590499</guid>
      <dc:creator>sergei-u-niq</dc:creator>
      <dc:date>2020-09-25T09:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257180#M4590500</link>
      <description>&lt;P&gt;Thank you Sergei for you answer.&lt;/P&gt;&lt;P&gt;I have already try to put my code in after-READ and it is triggered only in GET calls.&lt;/P&gt;&lt;P&gt;With PUT calls, CAP triggers after-UPDATE but before function _readAfterWrite so the result is incorrect. Calculeted fields are empty.&lt;/P&gt;&lt;P&gt;Moreover in &lt;A href="https://cap.cloud.sap/docs/node.js/api#srv-after"&gt;CAP's documentation&lt;/A&gt; you can see this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1849549-hrrfu.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 10:21:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257180#M4590500</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-09-25T10:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257181#M4590501</link>
      <description>&lt;P&gt;With a PUT call, CAP triggers these events in that orders:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;srv.ON (event UPDATE)&lt;/LI&gt;&lt;LI&gt;srv.AFTER (event UPDATE)&lt;/LI&gt;&lt;LI&gt;_readAfterWrite&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Never call after-READ  or on-READ.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 10:46:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257181#M4590501</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-09-25T10:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257182#M4590502</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Your service-level handlers for read shall not be invoked during non-read events, as this could have unintended consequences. However, your use case is certainly valid and we will discuss it.&lt;/P&gt;&lt;P&gt;In the meantime, you could lower your read handler to the database-level, where it would get invoked, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl(async function () {
  const DatabaseService = await cds.connect.to('db')
  DatabaseService.after('READ', '&amp;lt;qualifier&amp;gt;.RemoteConnections', function (data, req) {
    for (let row of data) {
      row.description = '&amp;lt;computed value&amp;gt;'
    }
  })
})
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 17:27:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257182#M4590502</guid>
      <dc:creator>vansyckel</dc:creator>
      <dc:date>2020-09-25T17:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257183#M4590503</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;vansyckel&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;I've treied to test your solution but this hanlder is never triggered. &lt;/P&gt;&lt;P&gt;I've put a console.log inside my function _setDescriptions and it is never called; both in GET and PUT calls.&lt;/P&gt;&lt;P&gt; Maybe I'm wrong something.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl (async function(){
	const DatabaseService = await cds.connect.to('db');
	DatabaseService.on('READ', 'RemoteConnections', _setDescriptions);	
	
	this.before("*", _isAuthenticated );
	this.before("CREATE", "AppUsers", _validateCreateAppUsers );
	this.before("*", _checkRoleBinding );
		
	this.before(["CREATE", "UPDATE"], "AppUsers", _setMailLowerCase );	
	this.before("CREATE", _fillCreatedBY );
	this.before("UPDATE", _fillChangedBY );
	this.before("CREATE", "Messages", _setDefaultMessage );	 
	
	this.on("changeUserPassword", _changeUserPassword);
	this.on("checkRemoteSystem", "RemoteConnections",_checkRemoteSystem);
});&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:28:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257183#M4590503</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-09-28T13:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257184#M4590504</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt; ,&lt;/P&gt;&lt;P&gt;That was my bad, sorry. You need to register using the fully qualified name of the entity (e.g., "my.bookshop.RemoteConnections"), as the database service may serve multiple service models and, hence, the service-local entity name ("RemoteConnections") may not be unique. I've updated my answer above.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:44:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257184#M4590504</guid>
      <dc:creator>vansyckel</dc:creator>
      <dc:date>2020-09-29T14:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257185#M4590505</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;vansyckel&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;thank you for you help, but I've tried also this new solution and unfortunatly It doesn't work.&lt;/P&gt;&lt;P&gt;Event is not triggered yet.&lt;/P&gt;&lt;P&gt;I've tried both this possibility but nothing:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl (async function(){
	const db = await cds.connect.to('db');
	db.on("READ", "&amp;lt;qualifier&amp;gt;.RemoteConnections", _setDescriptions);

	........
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl (async function(){
	const db = await cds.connect.to('db');
	const {RemoteConnections} = db.entities("&amp;lt;qualifier&amp;gt;");
	db.on("READ", RemoteConnections, _setDescriptions);	
	
	......
});&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I try test db.BEFORE, it is triggered but the calculation fields are empty.&lt;/P&gt;&lt;P&gt;Thank you for you help.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 13:27:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257185#M4590505</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-09-30T13:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257186#M4590506</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;"&amp;lt;qualifier&amp;gt;" was meant as a placeholder to make the entity name fully qualified, as I don't know your model.&lt;/P&gt;&lt;P&gt;Example: Given &lt;A href="https://github.com/SAP-samples/cloud-cap-samples/blob/master/bookshop/srv/cat-service.cds" target="_blank"&gt;this cds model&lt;/A&gt;, you can register a handler for the service entity "CatalogService.Books" or the database entity "sap.capire.bookshop.Books", i.e., the "&amp;lt;qualifier&amp;gt;" is either "CatalogService" or "sap.capire.bookshop".&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 18:26:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257186#M4590506</guid>
      <dc:creator>vansyckel</dc:creator>
      <dc:date>2020-10-01T18:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257187#M4590507</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;vansyckel&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;sorry
for the misunderstanding, I've put my namespace in the actual code. &lt;/P&gt;&lt;P&gt;Here
in the blog I put &amp;lt;Qualifier&amp;gt; just to not show my namespace. &lt;/P&gt;&lt;P&gt;So
the problem is real not my misinterpretation of the suggestion.&lt;/P&gt;&lt;P&gt;Now I show
you the exactly code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;using {it.conse.wispin.users as wispinUsers } from '../db/users-model';
service WispinService @(path:'/odata/wispinService') {
  @Capabilities: { Insertable:true,Updatable:true, Deletable:true }
  entity RemoteConnections as projection on  wispinUsers.RemoteConnections;
}          &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl (async function(){
	const db = await cds.connect.to('db');
	db.on("READ", "it.conse.wispin.users.RemoteConnections", _setDescriptions);

	........
});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;module.exports = cds.service.impl (async function(){
	const db = await cds.connect.to('db');
	const {RemoteConnections} = db.entities("it.conse.wispin.users");
	db.on("READ", RemoteConnections, _setDescriptions);	
	
	......
});&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 07:46:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257187#M4590507</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-10-02T07:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257188#M4590508</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;My bad again, sorry! It needs to be db.after not db.on, as you want to augment the result and not override the result fetching itself. I'll update my answer above.&lt;/P&gt;&lt;P&gt;BTW, The reason why your code is not called if using db.on is that the on phase is an interceptor stack and you'd need to &lt;A href="https://cap.cloud.sap/docs/node.js/api#srv-prepend" target="_blank"&gt;prepend&lt;/A&gt; your handler (db.on(...) appends).&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 14:16:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257188#M4590508</guid>
      <dc:creator>vansyckel</dc:creator>
      <dc:date>2020-10-05T14:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257189#M4590509</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;vansyckel&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;thank you for you help but unfortunatly this solution doesn't work.&lt;/P&gt;&lt;P&gt;Problems are:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;handler is triggered only for CREATE or UPDATE events. If I put only READ handler is not trigger because my call is PUT (change) or POST (create).&lt;/LI&gt;&lt;LI&gt;however, evenif my handler is triggerd with the below code, data in the oData's response is not correct. Descrition is not set&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;const db = await cds.connect.to('db');
const {RemoteConnections} = db.entities("it.conse.wispin.users");
db.after(["READ","CREATE","UDPATE"], RemoteConnections, async function(data, req) {
      " Set my description
}
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;
&lt;LI&gt;your suggestion is below but row has no property description; it has data.results as an object array &lt;STRONG&gt;data.results[0][2] = 'my description'&lt;/STRONG&gt;;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;function (data, req) {
    for (let row of data) {
      row.description = '&amp;lt;computed value&amp;gt;'
    }
  })&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So my problem is the result of PUT and POST event that are not changed.&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 10:51:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257189#M4590509</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-10-07T10:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257190#M4590510</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;alicegavanelli&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Please see the working example below.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sebastian&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;/*
 * db/data-model.cds
 *
namespace my.bookshop;

entity ReadAfterWrite {
  key ID        : Integer;
  text1         : String;
  virtual text2 : String;
}
*/

/*
 * srv/raw-service.cds
 *
using my.bookshop as my from '../db/data-model';

service ReadAfterWriteService {
  entity ReadAfterWrite as projection on my.ReadAfterWrite;
}
*/

/*
 * srv/raw-service.js
 */
const cds = require('@sap/cds')

module.exports = async function() {
  const { ReadAfterWrite } = this.entities //&amp;gt; ReadAfterWriteService.ReadAfterWrite
  const DatabaseService = await cds.connect.to('db')
  // register for ReadAfterWriteService.ReadAfterWrite as this is the target of the SELECT query
  DatabaseService.after('each', ReadAfterWrite, (row) =&amp;gt; { //&amp;gt; invoked for each row of a READ result
    row.text2 = 'virtual text'
  })
}

/*
 * HTTP
 *
PUT &lt;A href="http://localhost:4004/read-after-write/ReadAfterWrite(1)" target="test_blank"&gt;http://localhost:4004/read-after-write/ReadAfterWrite(1)&lt;/A&gt;
Content-Type: application/json

{ "text1": "text on db" }

response:
{
  "@odata.context": "$metadata#ReadAfterWrite/$entity",
  "ID": 1,
  "text1": "text on db",
  "text2": "virtual text"
}
*/&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2020 10:07:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257190#M4590510</guid>
      <dc:creator>vansyckel</dc:creator>
      <dc:date>2020-10-08T10:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257191#M4590511</link>
      <description>&lt;P&gt;Thank you very much &lt;SPAN class="mention-scrubbed"&gt;vansyckel&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;your solution works!!!!!!&lt;/P&gt;&lt;P&gt;Best.&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 10:50:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257191#M4590511</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-10-09T10:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: CAP; UPDATE method doesn't trigger READ hanlder after function _readAfterWrite</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257192#M4590512</link>
      <description>&lt;P&gt;Thank you Sebastian Van Syckel,&lt;/P&gt;&lt;P&gt;the right answer is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;/*
 * srv/raw-service.js
 */
const cds = require('@sap/cds')

module.exports = async function() {
  const { ReadAfterWrite } = this.entities //&amp;gt; ReadAfterWriteService.ReadAfterWrite
  const DatabaseService = await cds.connect.to('db')
  // register for ReadAfterWriteService.ReadAfterWrite as this is the target of the SELECT query
  DatabaseService.after('each', ReadAfterWrite, (row) =&amp;gt; { //&amp;gt; invoked for each row of a READ result
    row.text2 = 'virtual text'
  })
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Oct 2020 11:00:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-update-method-doesn-t-trigger-read-hanlder-after-function/qaa-p/12257192#M4590512</guid>
      <dc:creator>alicegavanelli</dc:creator>
      <dc:date>2020-10-09T11:00:13Z</dc:date>
    </item>
  </channel>
</rss>

