Editar

Compartilhar via


order element

Specifies a sort order for the rows of the results.

Learn how to order rows using FetchXml.

Example

This example return account records in ascending order by createdon, name, and accountnumber values.

<fetch>
  <entity name='account'>
    <attribute name='name' />
    <attribute name='accountnumber' />
    <attribute name='createdon' />
    <order attribute='createdon' />
    <order attribute='name' />
    <order attribute='accountnumber' />
  </entity>
</fetch>

Attributes

Name Required? Description
attribute Yes The name of the attribute element to sort the data by.
alias No The alias of the attribute element to sort the data by
descending No Whether to sort the data in descending order.
entityname No Use this attribute to specify sort order for link-entity elements so that they aren't applied last. In an order within an entity element, set entityname to the alias value of a link-entity. Learn how to apply link-entity orders first

Parent elements

Name Description
entity Specifies the child element for a fetch element, the 'parent entity' for the query. Only one entity is allowed.
link-entity Joins a table related to the entity or link-entity to return additional columns with the result. Also used with filter elements to apply conditions on column values in related tables.