Sorting a list of record acquired from the zoho.crm.searchRecords function.
This is something for which I'm trying to figure out a straightforward way to do.
The searchRecords does a great job fetching me the records that I want. However, in some cases, where it returns multiple records, I want it to sort the returned list by date of creation of that record, so that when I do records.get(0), I get the most recent record.
As an example, here's my sample pseudo code:
- records = zoho.crm.searchRecords("Clients", "Office_Number:equals:123456");
Now the "records" list above contains all clients who have the office number 123456. Because it's sometimes the case that multiple clients have the same office number, I want to work with only the most recently created client. Such that when I index the records list for the first item, I get the most recently created client. E.g.:
- records.sortList(sort_by = "Created_Time") // just an example pseudo function
- most_recent_client = records.get(0)