<?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: SF API Select Using Navigation Property in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670259#M4753571</link>
    <description>&lt;P&gt;I guess Frank showed the key to solve the issue, which is the initialization of the "userApi"&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;const userApi = service.pltUserManagementService().userApi&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In general, this &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/execute-request"&gt;documentation&lt;/A&gt; shows how to execute an odata request.&lt;/P&gt;&lt;P&gt;In addition, for odata v2 specific details you can check &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client"&gt;this&lt;/A&gt; documentation, where you can find e.g., how to "$select" properties &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client#select"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2022 06:19:24 GMT</pubDate>
    <dc:creator>Junjie</dc:creator>
    <dc:date>2022-12-02T06:19:24Z</dc:date>
    <item>
      <title>SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaq-p/12670252</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I'm using Cloud SDK for Javascript to fetch some data from SF OData API. It's working smoothly. ( Foundation platform, User Management API )&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;const getUserData = async function (userId) {
  const userApi = new UserApi();
  const resp = await userApi
    .requestBuilder()
    .getAll()
    .select(
      userApi.schema.USER_ID,
      userApi.schema.JOB_CODE,
      userApi.schema.DIVISION,
      userApi.schema.CUSTOM_01,
      userApi.schema.CUSTOM_02,
      userApi.schema.CUSTOM_03,
      userApi.schema.CUSTOM_04,
      userApi.schema.TOTAL_TEAM_SIZE,
      userApi.schema.DEFAULT_FULL_NAME,
      userApi.schema.LOCATION,
      userApi.schema.TITLE
    )
    .filter(userApi.schema.USER_ID.equals(userId))
    .execute({ destinationName: _dest });
  return resp;
};&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;But when I add a navigation property to select at the bottom of the TITLE like;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;userApi.schema.HR&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;it's throwing an error (Cannot read properties of undefined (reading '_fieldName')) &lt;/P&gt;
  &lt;P&gt;When I add it like this;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;userApi.schema.HR.select(userApi.schema.USER_ID)&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;It also throws an error ( Cannot read properties of undefined (reading 'select') )&lt;/P&gt;
  &lt;P&gt;I also couldn't find a specific schema for that Navigation Property (HR).&lt;/P&gt;
  &lt;P&gt;Any ideas how to get navigation properties ?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 08:36:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaq-p/12670252</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2022-11-28T08:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670253#M4753565</link>
      <description>&lt;P&gt;Great that you use the SDK and it also runs smooth in most cases.&lt;/P&gt;&lt;P&gt;Before I investigate the problem using your service, could you try one quick thing. Can you get the api via the service object as describede here: &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client#select" target="test_blank"&gt;https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client#select&lt;/A&gt; &lt;/P&gt;&lt;P&gt;const { businessPartnerApi, businessPartnerAddressApi } =&lt;BR /&gt;  businessPartnerService();&lt;BR /&gt;businessPartnerApi&lt;BR /&gt;  .requestBuilder()&lt;BR /&gt;  .getAll()&lt;BR /&gt;  .select(&lt;BR /&gt;    businessPartnerApi.schema.FIRST_NAME,&lt;BR /&gt;    businessPartnerApi.schema.TO_BUSINESS_PARTNER_ADDRESS.select(&lt;BR /&gt;      businessPartnerAddressApi.schema.ADDRESS_ID,&lt;BR /&gt;      businessPartnerAddressApi.schema.CITY_CODE&lt;BR /&gt;    )&lt;BR /&gt;  )&lt;BR /&gt;  .execute(destination);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We do some init stuff within the service object. Let me know if it helps. If not I try to reproduce the error. Also if you face issues in the future feel free to open an issue on our OS repo: &lt;A href="https://github.com/SAP/cloud-sdk-js/issues" target="test_blank"&gt;https://github.com/SAP/cloud-sdk-js/issues&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We monitor all channels but the repo is our preferred one since it integrates best with our daily work flow.&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 10:09:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670253#M4753565</guid>
      <dc:creator>frank_essenberger1</dc:creator>
      <dc:date>2022-11-28T10:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670254#M4753566</link>
      <description>&lt;P&gt;Thanks Frank for your quick response. Actually that link is a great source of information. I've been using it since the beginning but I couldn't find the type that HR navigation property is represented like businessPartnerAddressApi .&lt;/P&gt;&lt;P&gt;Also there is no UserService that I can use and I couldn't find HR definition in any of the classes.&lt;/P&gt;&lt;P&gt;Could this problem be specific to the SF APIs ? I can open an issue if you want to continue on that channel.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2113814-image.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const { UserApi } = require("../generated/plt-user-mng/UserApi");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Dependencies;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    "@sap-cloud-sdk/connectivity": "^2.10.0",&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    "@sap-cloud-sdk/core": "^1.54.2",&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    "@sap-cloud-sdk/odata-v2": "^2.10.0",&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    "@sap-cloud-sdk/generator": "^2.10.0",&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 12:58:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670254#M4753566</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2022-11-28T12:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670255#M4753567</link>
      <description>&lt;P&gt;The service object contains all APIs, it is a sort of umbrella object. This object has all the apis. I generated the code and added a navigation property (HR). I have no SFSF to test a actual call so I just generated the URL:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;const service = require('./plt-user-management-service/service')&lt;BR /&gt;&lt;BR /&gt;const userApi = service.pltUserManagementService().userApi&lt;BR /&gt;&lt;BR /&gt;userApi.requestBuilder().getAll().select(userApi.schema.NICKNAME, userApi.schema.HR)&lt;BR /&gt;    .url({url: 'http://foo.com'})&lt;BR /&gt;    .then(url =&amp;gt; console.log(url))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which gives me in the console:&lt;/P&gt;&lt;P&gt;&lt;A href="http://foo.com/successfactors/odata/v2/User?$select=hr/*,nickname&amp;amp;$expand=hr" target="test_blank"&gt;http://foo.com/successfactors/odata/v2/User?$select=hr/*,nickname&amp;amp;$expand=hr&lt;/A&gt;&lt;/P&gt;which looks ok. Can you give it a try using the service and access the userApi not via the constructor directly. You can also remove the core package, since it is version 1 which is not needed when you have the more granular version 2 packages.BestFrank</description>
      <pubDate>Mon, 28 Nov 2022 16:16:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670255#M4753567</guid>
      <dc:creator>frank_essenberger1</dc:creator>
      <dc:date>2022-11-28T16:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670256#M4753568</link>
      <description>&lt;P&gt;I also tried with the `new UserApi()` and I got the error `TypeError: Cannot read properties of undefined (reading '_fieldName')`. So I am pretty sure the error should go away when you access it via the service as indicated by the snippet above.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 16:18:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670256#M4753568</guid>
      <dc:creator>frank_essenberger1</dc:creator>
      <dc:date>2022-11-28T16:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670257#M4753569</link>
      <description>&lt;P&gt;Thanks so much Frank! It worked. Though I didn't get why it wasn't working with the first approach. Or the difference between these two calls. &lt;/P&gt;&lt;P&gt;One thing to note, when I try getting specific fields of the navigation prop, it's woorking.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  const resp = await userApi
    .requestBuilder()
    .getAll()
    .select(
      userApi.schema.USER_ID,
      userApi.schema.TITLE,
      userApi.schema.HR.select(userApi.schema.USER_ID)
    )
&lt;/CODE&gt;&lt;/PRE&gt;But when I try to select all as you proposed above, it throws an error related with the * at the beginning of constructed url.&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;  const resp = await userApi
    .requestBuilder()
    .getAll()
    .select(
      userApi.schema.USER_ID,
      userApi.schema.TITLE,
      userApi.schema.HR
    )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Unable to understand API request with character sequence: hr/*,userId,jobCode,division,custom01,custom02,custom03,custom04,totalTeamSize,defaultFullName,location,title&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 17:05:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670257#M4753569</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2022-11-28T17:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670258#M4753570</link>
      <description>&lt;P&gt;The difference is that when you access it via the service (intenden way) some getters are invoked which initialize some fields. The problem is that JS does not have any proper protection so even if we mark the constructor as private you could still use it. &lt;/P&gt;&lt;P&gt;Why the `*` is not working is not clear to me. I think it is proper OData notation, however sometimes the backend systems do not implement all OData features correctly. I hope the selection of the explicit fields is acceptable for your usecase? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 07:07:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670258#M4753570</guid>
      <dc:creator>frank_essenberger1</dc:creator>
      <dc:date>2022-11-29T07:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670259#M4753571</link>
      <description>&lt;P&gt;I guess Frank showed the key to solve the issue, which is the initialization of the "userApi"&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;const userApi = service.pltUserManagementService().userApi&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In general, this &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/execute-request"&gt;documentation&lt;/A&gt; shows how to execute an odata request.&lt;/P&gt;&lt;P&gt;In addition, for odata v2 specific details you can check &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client"&gt;this&lt;/A&gt; documentation, where you can find e.g., how to "$select" properties &lt;A href="https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client#select"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 06:19:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670259#M4753571</guid>
      <dc:creator>Junjie</dc:creator>
      <dc:date>2022-12-02T06:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: SF API Select Using Navigation Property</title>
      <link>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670260#M4753572</link>
      <description>&lt;P&gt;I've just seen your comment. Yes that is enough in my case. I had already found a workaround but I was curious about the cloud SDK call and your answer showed me the way of accessing the service via the service &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; . I did replace this with my workaround.&lt;/P&gt;&lt;P&gt;Thanks again for your help and your comment on the difference. &lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 07:34:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sf-api-select-using-navigation-property/qaa-p/12670260#M4753572</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2022-12-02T07:34:58Z</dc:date>
    </item>
  </channel>
</rss>

