SAP Knowledge Base Article - Public

3736899 - Is it possible to retrieve org. chart structure via API?

Symptom

Inquiry whether the organization chart (company structure overview) can be retrieved/read directly via the OData API.

Environment

SAP SuccessFactors HCM Suite

Cause

Resolution

Yes, it is possible, though not in a simple way.

The Org Chart page retrieves data from multiple records and objects and applies an internal logic to construct the hierarchy.

To reproduce the same behavior through the OData API, this logic must be recreated externally.

                       

To achieve this, you may need to build an integration that calls the User entity (using a starting user ID as a variable) and then performs recursive OData calls to follow the manager relationship, continuing until no additional manager exists (manager = null).

Please, note this is just a suggestion that you could explore or bring to your integration consultant. This is outside support's knowledge and scope.

            

High-Level Approach

1) Use a variable in the request URL

Initial URL: GET https://<API_URL>/odata/v2/User('{{START_USER_ID}}')?$format=json&$select=userId,firstName,lastName,manager/userId,manager/firstName,manager/lastName&$expand=manager

2) Create a recursive script for querying manager data until is null

Pseudocode example:
 
currentId = START_USER_ID
seen = empty set
chain = empty list
MAX_DEPTH = 50   // safety

repeat up to MAX_DEPTH times:
    if currentId in seen: break   // safety: avoid loops
    add currentId to seen

    response = HTTP GET
      /odata/v2/User('currentId')
        ?$format=json
        &$select=userId,firstName,lastName,manager/userId,manager/firstName,manager/lastName
        &$expand=manager

    user = response.d (or response)
    append (user.userId, user.firstName, user.lastName) to chain

    nextId = user.manager.userId if present else null
    if nextId is null: break

    currentId = nextId

return chain

3) Run it

        

See Also

refer to: Is it possible to export photos on the Organization Chart?

refer to: How to export SuccessFactors attachments using OData API

Keywords

organization, chart, org chart, company structure overview, odata api, export image, export pdf, retrieve org chart, orgchart picture, successfactors api, organizational, structure, image export, pdf export, integration, attachments, api retrieval , KBA , LOD-SF-INT-ODATA , OData API Framework , Problem

Product

SAP SuccessFactors HCM Suite all versions