Default SortInfo inside an a!queryEntity

 

Hi everyone, 

So, I have one CDT called "SA_Clients" with the attributes id (integer), name (text) and address (text). When I try to retrieve all the data from the DB, I use the following Expression Rule:

a!queryEntity(
entity: cons!SA_CLIENTS_CONSTANT,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1
)
)
)

In the result I receive what I expect but with the "SortInfo" ""activated"". This appears in the response: "sort: List of SortInfo: 1 item SortInfo field: "address" ascending: true". 

I don't want this. Is there anyway to solve this?

 

Thanks in advance

  • a!queryEntity requires sorting information when run, and if none is supplied it'll pick a column (i forget how exactly) to return as the default sort. The way to counteract this is to pass in the column *you* want it to sort on by default.
  • As Mike indicates, you'll want to include a manual override of the sort info, e.g
    a!queryEntity(
    entity: cons!SA_CLIENTS_CONSTANT,
    query: a!query(
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: -1,
    sort: a!sortInfo(
    field: "DifferentField",
    ascending:false

    )
    )
    )
    )
  • In reply to Mike Schmitt:

    Hi Mike,

    Maybe the best way to get the info from the DB like "SELECT * FROM db_name" is to use sort by id, ascending.

    Thanks
  • In reply to Richard:

    Hi Richard,

    Maybe the best way to get the info from the DB like "SELECT * FROM db_name" is to use sort by id, ascending.

    Thanks

 Discussion posts and replies are publicly visible