Sorting through orderBy element in the input XML of list APIs

The input XML of list APIs supports sorting based on the OrderBy element.

To form queries:

Edit the custom input XML of any list API, and add the OrderBy element. Add the Attribute child element, and in the Name attribute specify the name of the field based on which you want to sort the results.

The OrderBy element supports ordering of the attributes in both ascending and descending order. By default, the results are sorted in ascending order. If you want to sort the results in descending order, add the Desc attribute to the Attribute element and set it to Y.

You can also do nested sorting using the OrderBy element.

GetOrganizationList API input XML with orderBy element

The following example shows a fragment of the input XML that returns a list of organizations and results are sorted by the OrganizationName attribute.

<Organization IgnoreOrdering="N" MaximumRecords="5000"> 
  <OrderBy> 
     <Attribute Name="OrganizationName"/> 
   </OrderBy> 
</Organization> 

GetOrganizationList API input XML with nested orderBy element

The following example shows a fragment of the input XML that returns a list of organizations and results are sorted by OrganizationName and LocaleCode attributes.

<Organization IgnoreOrdering="N" MaximumRecords="5000"> 
   <OrderBy> 
     <Attribute Name="OrganizationName"/> 
     <Attribute Name="LocaleCode"/> 
    </OrderBy> 
</Organization> 

GetOrganizationList API input XML with orderBy element and desc attribute

The following example shows a fragment of the input XML that returns a list of organizations and results are sorted by the OrganizationName attribute in the descending order.

<Organization IgnoreOrdering="N" MaximumRecords="5000"> 
   <OrderBy> 
      <Attribute Name="OrganizationName" Desc="Y"/> 
   </OrderBy> 
</Organization>