The OrderBy
keyword is used to sort the result-set in ascending or descending order and includes pagination.
The general format for OrderBy
statement is as follows:
{
"OrderBy": {
"Fields": [
{
"{FieldKey1}": "ASC"
},
{
"{FieldKey2}": "DESC"
}
],
"PageKey": "{PageKey}",
"PageSize": 10,
}
}
Here, {FieldKey}
are the names of the object field, such as "LastName" or "CompanyName." {PageKey}
is key to the desired page (Octopus API returns the key of the next page in the response). {PageSize}
is a number of records on each page.
Ordering
OrderBy - 10 contacts ordered by the LastName
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"Fields": [
{
"LastName": "ASC"
}
]
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}
OrderBy - 10 contacts ordered by the LastName, reverse order
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"Fields": [
{
"LastName": "DESC"
}
]
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}
Pagination
OrderBy - Contacts ordered by the Creation Date, page 1
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"PageKey": null,
"PageSize": 10,
"Fields": [
{
"CreationDate": "ASC"
}
]
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}
OrderBy - Contacts ordered by the Creation Date, page 2
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"PageKey": "MTA=",
"PageSize": 10,
"Fields": [
{
"CreationDate": "ASC"
}
]
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}
OrderBy - Contacts, page 1
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"PageKey": null,
"PageSize": 10
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}
OrderBy - Contacts, page 2
Use the AbEntryRead
method to search for Address Book entries in the database.
// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
"AbEntry": {
"Scope": {
"Fields": {
"Key": 1,
"FirstName": 1,
"LastName": 1
}
},
"Criteria": {
"SearchQuery": {
"Type": {
"$EQ": "Contact"
}
},
"Top": 10
},
"OrderBy": {
"PageKey": "MTA=",
"PageSize": 10
}
},
"Configuration": {
"Drivers": {
"IAbEntrySearcher": "Maximizer.Model.Access.Sql.AbEntrySearcher"
}
}
}