<?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 com.sap.cloud.server.odata.core.UndefinedException while using filter with expanded entity in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/com-sap-cloud-server-odata-core-undefinedexception-while-using-filter-with/m-p/12230109#M1984372</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;While running the following query &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;/ProductSet?$expand=SellerDetails&amp;amp;$filter=SellerDetails/FullName eq `Seller1` &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I get the following error&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;com.sap.cloud.server.odata.core.UndefinedException: Cannot get property 'SellerDetails' of type 'mykartns.Seller' in entity type 'mykartns.Product', because the value is not set. This exception occurs because an undefined property is considered distinct from a null property (regardless of whether or not the property is defined as nullable in the service metadata). The attempt to access an undefined property may be evidence of a flaw in this client application (trying to access properties in a query result without having requested for the server to return values for the properties, or trying to access property values before initializing them), or may be evidence of a flaw in the service implementation (failing to return properties that were requested by the client application using $select or $expand). Depending on the root cause, options to avoid this exception include: (1) Using DataQuery.expand before executing a query (or in the query parameter to DataService.loadEntity) to ensure that navigation properties are requested from the server before trying to access them; (2) Using DataService.loadProperty to ensure that navigation properties are requested from the server before trying to access them; (3) Getting the service implementer to fix the service if it is unexpectedly omitting expected property values in responses; (4) Initializing all properties in newly created objects before trying to access the properties (using the 'setDefaultValues' function, or by specifying 'true' for the 'withDefaults' parameter of the proxy class constructor); (5) Using the 'hasDataValue' function to check if properties are defined before trying to access them; (6) With the dynamic API, using the 'getOptionalValue' function instead of using the 'getDataValue' function.&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;Attaching the metadata.txt for reference&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Ashish&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/1840770-metadata.txt"&gt;metadata.txt&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Sep 2020 18:46:07 GMT</pubDate>
    <dc:creator>ashishjain14</dc:creator>
    <dc:date>2020-09-07T18:46:07Z</dc:date>
    <item>
      <title>com.sap.cloud.server.odata.core.UndefinedException while using filter with expanded entity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/com-sap-cloud-server-odata-core-undefinedexception-while-using-filter-with/m-p/12230109#M1984372</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;While running the following query &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;/ProductSet?$expand=SellerDetails&amp;amp;$filter=SellerDetails/FullName eq `Seller1` &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I get the following error&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;com.sap.cloud.server.odata.core.UndefinedException: Cannot get property 'SellerDetails' of type 'mykartns.Seller' in entity type 'mykartns.Product', because the value is not set. This exception occurs because an undefined property is considered distinct from a null property (regardless of whether or not the property is defined as nullable in the service metadata). The attempt to access an undefined property may be evidence of a flaw in this client application (trying to access properties in a query result without having requested for the server to return values for the properties, or trying to access property values before initializing them), or may be evidence of a flaw in the service implementation (failing to return properties that were requested by the client application using $select or $expand). Depending on the root cause, options to avoid this exception include: (1) Using DataQuery.expand before executing a query (or in the query parameter to DataService.loadEntity) to ensure that navigation properties are requested from the server before trying to access them; (2) Using DataService.loadProperty to ensure that navigation properties are requested from the server before trying to access them; (3) Getting the service implementer to fix the service if it is unexpectedly omitting expected property values in responses; (4) Initializing all properties in newly created objects before trying to access the properties (using the 'setDefaultValues' function, or by specifying 'true' for the 'withDefaults' parameter of the proxy class constructor); (5) Using the 'hasDataValue' function to check if properties are defined before trying to access them; (6) With the dynamic API, using the 'getOptionalValue' function instead of using the 'getDataValue' function.&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;Attaching the metadata.txt for reference&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Ashish&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/1840770-metadata.txt"&gt;metadata.txt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 18:46:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/com-sap-cloud-server-odata-core-undefinedexception-while-using-filter-with/m-p/12230109#M1984372</guid>
      <dc:creator>ashishjain14</dc:creator>
      <dc:date>2020-09-07T18:46:07Z</dc:date>
    </item>
  </channel>
</rss>

