on ‎2022 Nov 28 8:36 AM
Hi,
I'm using Cloud SDK for Javascript to fetch some data from SF OData API. It's working smoothly. ( Foundation platform, User Management API )
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;
};
But when I add a navigation property to select at the bottom of the TITLE like;
userApi.schema.HR
it's throwing an error (Cannot read properties of undefined (reading '_fieldName'))
When I add it like this;
userApi.schema.HR.select(userApi.schema.USER_ID)
It also throws an error ( Cannot read properties of undefined (reading 'select') )
I also couldn't find a specific schema for that Navigation Property (HR).
Any ideas how to get navigation properties ?
Request clarification before answering.
Great that you use the SDK and it also runs smooth in most cases.
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: https://sap.github.io/cloud-sdk/docs/js/features/odata/v2-client#select
const { businessPartnerApi, businessPartnerAddressApi } =
businessPartnerService();
businessPartnerApi
.requestBuilder()
.getAll()
.select(
businessPartnerApi.schema.FIRST_NAME,
businessPartnerApi.schema.TO_BUSINESS_PARTNER_ADDRESS.select(
businessPartnerAddressApi.schema.ADDRESS_ID,
businessPartnerAddressApi.schema.CITY_CODE
)
)
.execute(destination);
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: https://github.com/SAP/cloud-sdk-js/issues
We monitor all channels but the repo is our preferred one since it integrates best with our daily work flow.
Best
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
Also there is no UserService that I can use and I couldn't find HR definition in any of the classes.
Could this problem be specific to the SF APIs ? I can open an issue if you want to continue on that channel.

const { UserApi } = require("../generated/plt-user-mng/UserApi");
Dependencies;
"@sap-cloud-sdk/connectivity": "^2.10.0",
"@sap-cloud-sdk/core": "^1.54.2",
"@sap-cloud-sdk/odata-v2": "^2.10.0",
"@sap-cloud-sdk/generator": "^2.10.0",
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.