Querying for a Siebel CRM Business Component with a Sort Specification
You can query for a particular Siebel CRM Business Component, and sort its response in either an ascending or descending order by stating the sortspec parameter in the request. This provides you with a REST Get API response that is already sorted in a particular order, without the need to code any additional sorting scripts.
The sortspec parameter contains a comma separated list of field:sortorder pairs where spaces before and after the equals sign (=) and colon ( : ) are ignored. For example:
sortspec=First Name:desc,Last Name:asc
The keywords for ascending and descending order are asc
and
desc
respectively. In the following example, the query first sorts
the records in ascending order of Citizenship, and then in ascending order of First
Name.
http://ServerName:port/siebel/v1.0/data/Account/1-1/Contact?
sortspec=Citizenship:asc,First Name:asc
The sortspec parameter is only applied to the leaf node, or the last child object in the URI. In the previous example, this is the Contact business component.
When using the sortspecparameter, the following considerations apply:
-
If you do not specify the sortspec parameter, or if nothing is specified after the equals sign (=) in the sort specification, then the response is not sorted.
-
When neither an ascending nor descending sort order is specified, the response is sorted in ascending order by default.
-
This parameter applies only to GET URLs of /data and /workspace APIs.
-
You can only use the sortspec parameter on a collection query. If you use it in a single record query, then the sortspec parameter has no effect.
-
You can sort at any level of object (child object, grandchild object, and so on), however, you can apply sortspec to the last object, or the leaf object, in the URI.
-
To avoid an impact on API performance, only use the sortspec parameter when sorting is necessary.
In the following request, the sortspec parameter is set to
First Name:desc
, so the returned response is sorted by the field
First Name in descending order.
-
Request URI: http://ServerName:port/siebel/v1.0/data/Account/Account/1-5GZO/Contact?sortspec = First Name : desc & Fields=First Name
-
HTTP Method: GET
-
Content-Type: application/json
-
Authorization: Basic
-
Request Body: None
Here are the response details for a successful request:
-
HTTP Code: 200
-
Content-Type: application/json
-
Response Body:
"items": [ { "Id": "24-287Y", "First Name": "Roger", "Link": [ ….. ] }, { Id": "1-57LT", "First Name": "John", "Link": [ ….. }, { "Id": "1-A9NW", "First Name": "Henry", "Link": [ ….. } ], "Link": [ …. }
In the following request, the sortspec parameter is set to
First Name:asc
, so the returned response is sorted by the field
First Name in ascending order.
-
Request URI: http://ServerName:port/siebel/v1.0/data/Account/Account/1-5GZO/Contact?sortspec = First Name : asc & Fields=First Name
-
HTTP Method: GET
-
Content-Type: application/json
-
Authorization: Basic
-
Request Body: None
Here are the response details for a successful request:
-
HTTP Code: 200
-
Content-Type: application/json
-
Response Body:
{ "items": [ { "Id": "1-AJ3J", "First Name": "Felix", "Link": [ …. ] }, { "Id": "1-A9NW", "First Name": "Henry", "Link": [ …. ] }, { "Id": "1-57LT", "First Name": "John", "Link": [ …. ] } ], "Link": [ …. ] }