SAP Knowledge Base Article - Public

3617798 - Sorting Custom Fields in a GET API

Symptom

This document provides guidance on how to sort custom fields in a GET API call for SAP Sales and Service Cloud Version 2. 

Environment

  • SAP Sales Cloud Version 2
  • SAP Service Cloud Version 2

Reproducing the Issue

  1. Click on the User Icon.
  2. Go to the Settings > All Settings.
  3. Go to the Extensibility Administration.
  4. Select an Entity (e.g. Account, Opportunity, Case etc.).
  5. Go to the Custom Fields tab.
  6. Create a Custom Field (e.g. ABC custom field).

Now, you want to retrieve it in a GET API call. 

Resolution

First you need to ensure that the Custom Field has "sortable" property set as "true". You need to navigate to  Extensibility Administration and then navigate to the Field Attributes tab. Ensure that the "sortable" property is set as "true".

Once verified, you can proceed with formulating the GET API call. Include the following syntax in your API GET request to sort by the custom field: 

                                           

$orderby=extensions/ZABC%20asc

                         
Example with the Case Service:

https://< Tenant URL >/sap/c4c/api/v1/case-service/cases?$orderby=extensions/<Custom Field Name>%20asc

                            

Make sure to replace "ZABC" with the actual name of your custom field. Following these steps ensures that your API call effectively retrieves and sorts the desired data, streamlining your data management processes.

See Also

Field Attributes

Keywords

sorting fields, sort custom fields, sort, sortable, custom fields, api, sorting into api , KBA , CEC-CRM-CZM-EXT , Extensibility for SAP Sales/Service Cloud , How To

Product

SAP Sales Cloud and SAP Service Cloud Version 2 1.0