cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SF API Select Using Navigation Property

huseyindereli
Active Contributor
0 Likes
19,884

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 ?

View Entire Topic
frank_essenberger1
Product and Topic Expert
Product and Topic Expert
0 Likes

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.