How can I fetch the latest entry created via server side or via API ??
I found order_by in get_list and its working through custom script but when trying via an api, its not working.
ANY Help ??
How can I fetch the latest entry created via server side or via API ??
I found order_by in get_list and its working through custom script but when trying via an api, its not working.
ANY Help ??
Query:
/api/resource/User?fields=["name", "creation"]&order_by=creation asc
Output
{
"data": [{
"creation": "2017-05-08 18:21:41.764494",
"name": "Administrator"
}, {
"creation": "2017-05-08 18:21:42.000328",
"name": "Guest"
}, {
"creation": "2017-05-08 18:24:51.976342",
"name": "saurabh@erpnext.com"
}, {
"creation": "2017-08-11 09:21:32.440045",
"name": "jogndoe@erpnext.com"
}, {
"creation": "2017-10-26 17:42:52.653960",
"name": "doe@erpnext.com"
}, {
"creation": "2017-11-01 16:42:42.492139",
"name": "reserller1@erpnext.com"
}, {
"creation": "2017-11-01 16:44:04.075349",
"name": "reseller2@erpnext.com"
}, {
"creation": "2017-11-01 16:45:41.983735",
"name": "reseller3@erpnext.com"
}, {
"creation": "2018-06-15 15:42:48.563616",
"name": "reseller4@erpnext.com"
}, {
"creation": "2018-06-21 10:54:41.040078",
"name": "reseller5@erpnext.com"
}, {
"creation": "2018-08-08 18:02:03.129113",
"name": "asd@asd.com"
}, {
"creation": "2018-08-08 18:05:39.058581",
"name": "sam@ap.c"
}, {
"creation": "2018-08-08 18:07:18.532556",
"name": "sam1@ap.c"
}, {
"creation": "2018-08-08 18:12:36.077270",
"name": "dq12sa@sd.co"
}, {
"creation": "2018-08-08 18:15:01.229618",
"name": "dq12sa1@sd.co"
}, {
"creation": "2018-08-08 18:15:15.309183",
"name": "ads@ads.co"
}, {
"creation": "2018-08-08 18:25:51.428487",
"name": "tavi@tect.co"
}, {
"creation": "2018-08-08 18:26:42.140110",
"name": "12@as.co"
}, {
"creation": "2018-08-08 18:47:14.888463",
"name": "asd+1@asd.com"
}, {
"creation": "2018-08-09 10:40:14.240504",
"name": "data@erp.com"
}]
}
If that also seems to be working, why this isn’t ??
Any help what I am doing wrong ?
frappe.get_list("My Doctype",fields=['"*"'],order_by="creation desc", limit_start=0, limit_page_length=5)
Its still returning first 5 entries
I ain;t getting whats happening wrong. By api, its gving correct value but when running via python, its giving first but I want last as order_by=‘creation desc’
This is my code
frappe.get_list("Logs",fields='"*"',order_by='creation desc',limit_page_length=5)
There’s a frappe.get_last_doc(doctype)
function, which returns the last created document in that DocType.
Not sure if there’ an API for it.
Solved it. Actually I was using frappeclient as an external file and in that get_list wasn’t having order_by’s code. So I added it there and it worked.