cancel
Showing results for 
Search instead for 
Did you mean: 

SF API Select Using Navigation Property

huseyindereli
Active Contributor
0 Kudos

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
Junjie
Advisor
Advisor
0 Kudos

I guess Frank showed the key to solve the issue, which is the initialization of the "userApi"

const userApi = service.pltUserManagementService().userApi

In general, this documentation shows how to execute an odata request.

In addition, for odata v2 specific details you can check this documentation, where you can find e.g., how to "$select" properties here.