<?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 action doesn't return data properly when called u... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaa-p/14091048#M4912494</link>
    <description>&lt;P&gt;The return value of the 'invokeAction()' function is an ODataV4Context on which the 'getObject()' function will return the data object.&lt;/P&gt;&lt;P&gt;See:&amp;nbsp;&lt;A href="https://sapui5.hana.ondemand.com/1.135.0/#/api/sap.ui.model.odata.v4.Context%23methods/getObject" target="_blank"&gt;https://sapui5.hana.ondemand.com/1.135.0/#/api/sap.ui.model.odata.v4.Context%23methods/getObject&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So in your code you can do&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.editFlow
  .invokeAction(sActionName, oParameters)
  .then(result =&amp;gt; {
    const data = result?.getObject()
    console.log(data?.value)
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 May 2025 04:31:16 GMT</pubDate>
    <dc:creator>Willem_Pardaens</dc:creator>
    <dc:date>2025-05-01T04:31:16Z</dc:date>
    <item>
      <title>CAP action doesn't return data properly when called using a custom action</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaq-p/14090937</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm using CAP(Node.js) with Fiori elements. I have a cap action that returns a string :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;on&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'CapAction'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;entity&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;async&lt;/SPAN&gt; &lt;SPAN&gt;req&lt;/SPAN&gt; &lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;"TEST"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }); &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I have also added a custom action using extension point &amp;amp; my requirement is such that i need to call the CAP action when the user click on custom button. Custom action's handler look like this :&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NewQS.PNG" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/256698i1314558A450EEF17/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NewQS.PNG" alt="NewQS.PNG" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;Now the the CAP action handler is being called and in the network tab of developer tools it's returning :&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;HTTP/1.1 200 OK&lt;BR /&gt;odata-version: 4.0&lt;BR /&gt;content-type: application/json;odata.metadata=minimal&lt;/P&gt;&lt;P&gt;{"@odata.context":"../$metadata#Edm.String","value":"TEST"}&lt;/P&gt;&lt;P&gt;But inside my custom handler the result variable shows :&lt;/P&gt;&lt;P&gt;d&amp;nbsp;{oModel: T, sPath: '/TestService(ID=6f76d291-9e2e-423a-bd16-1c7b7…true)/TestService.CapAction(...)', bForceRefresh: false, sDeepPath: '', oBinding: c,&amp;nbsp;…}&lt;/P&gt;&lt;P&gt;And the string "TEST" isn't being returned anywhere in this object. Any ideas how i can get the returned value ?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Apr 2025 21:44:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaq-p/14090937</guid>
      <dc:creator>David21</dc:creator>
      <dc:date>2025-04-30T21:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: CAP action doesn't return data properly when called u...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaa-p/14091048#M4912494</link>
      <description>&lt;P&gt;The return value of the 'invokeAction()' function is an ODataV4Context on which the 'getObject()' function will return the data object.&lt;/P&gt;&lt;P&gt;See:&amp;nbsp;&lt;A href="https://sapui5.hana.ondemand.com/1.135.0/#/api/sap.ui.model.odata.v4.Context%23methods/getObject" target="_blank"&gt;https://sapui5.hana.ondemand.com/1.135.0/#/api/sap.ui.model.odata.v4.Context%23methods/getObject&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So in your code you can do&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.editFlow
  .invokeAction(sActionName, oParameters)
  .then(result =&amp;gt; {
    const data = result?.getObject()
    console.log(data?.value)
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 04:31:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaa-p/14091048#M4912494</guid>
      <dc:creator>Willem_Pardaens</dc:creator>
      <dc:date>2025-05-01T04:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: CAP action doesn't return data properly when called u...</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaa-p/14091263#M4912522</link>
      <description>Appreciate the answer</description>
      <pubDate>Thu, 01 May 2025 11:23:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-action-doesn-t-return-data-properly-when-called-using-a-custom-action/qaa-p/14091263#M4912522</guid>
      <dc:creator>David21</dc:creator>
      <dc:date>2025-05-01T11:23:08Z</dc:date>
    </item>
  </channel>
</rss>

