ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Frappe call for getting limited(parameterized) data


#1

I am working on something and a question hammered in my mind. By default frappe.get_list fetches all the data and in future, I will be having over millions of data in a list. So i guess " function ( r ) "will be slow to load data . So for the resolution of that, what I want to do is fetching the first 10 at first time and on clicking next or any trigger i want next 10 values to be fetched.
Need help in getting values in limit and also how to put a trigger that on clicking this next 10 values to be loaded.

Here’s my code

frappe.call({
'method': 'frappe.client.get_list',
    'args':{
        'doctype': 'Doctype',
        'fields': ['name','data']
},
 async: false,  
    callback: function(r)

#2

You can try with start and limit in args:

frappe.call({
'method': 'frappe.client.get_list',
    'args':{
        'doctype': 'Doctype',
        'fields': ['name','data'],
        'start': 1,
        'limit': 10
},
 async: false,  
    callback: function(r)

#3

Not working. Still fetching all the data


#4
frappe.call({
'method': 'frappe.desk.reportview.get',

    'args':{
        'doctype': 'doctype',

        'fields': ['name','data'],

page_length:10


	

},
aysnc: false,
  
    callback: function(r)
{
console.log(r.message);
}
});

It’s giving first 10 values but any idea for trigger on how to load next 10 ??


#5

if you use method ‘frappe.client.get_list’, you can try below

frappe.call({
	'method': 'frappe.client.get_list',
    'args':{
        'doctype': 'Employee',
        'fields': ['name','employee_name'],
      	'limit_start':0,
      	'limit_page_length': 10
		},
		callback: function(r){
      if(r.message)
        console.log(r.message);
    }
  
});

It returns only 10 records. If want to load next 10, change only ‘limit_start’: 10.


#7

thanks @magic-overflow