Ordering
Note: Some API services do not support the capabilities described in this topic. See Service Feature Support for more information on the functionality supported by each API service.
Ordering
By default, P6 arranges API response objects in ascending order based on their ID values. Additionally, the P6 REST API supports response object ordering based on the values of other object properties. Sort endpoint response objects by using the following query parameter pattern:
/p6ws/restapi/<service>/<endpoint>?OrderBy=<ObjectId>,<Name>
Use the OrderBy
query parameter to order response objects based on a specified property. For example, the / p6ws/restapi/project?Fields=Id,Name&OrderBy=Id
endpoint arranges the contents of the returned response in ascending order based on the value of the Id
property.
Separate OrderBy
query parameter values with a comma to sort by additional properties. If two objects in a response have equal property values for the first OrderBy
query parameter value, the second property specified as an OrderBy
query parameter is used to order the response data. For example, the p6ws/restapi/project?Fields=Id,Name,OBSName&OrderBy=OBSName,Id
endpoint orders response objects in ascending order based on the value of the OBSName property. If two objects have equivalent OBSName property values, they are instead sorted in ascending order based on the value of the Id
property.
You can include an optional order
query parameter after each sort
query parameter value to arrange response objects in ascending or descending order. If no order
value is specified, sorted response objects are returned in ascending order. For example, the /p6ws/restapi/project?Fields=Id,Name&OrderBy=Id DESC
endpoint sorts response objects in descending order based on the value of the Id
property. You can also specify a sort order for each sort query parameter value, for example the /p6ws/restapi/project?Fields=Id,Name,OBSName&OrderBy=OBSName ASC,Id DESC
endpoint will arrange objects in ascending order based on the OBSName
property. If any response objects have equal owner property values, they will be sorted in descending order based on the value of the Id
property.
Notes:
You cannot order response objects based on properties that may contain more than one value.
You cannot order response objects based on the properties of nested objects.
The API supports OrderBy, but Jersey framework may give unexpected results. Use client-side sorting to make sure your results are sorted as expected.