How do I pass values for 'start', 'limit', and 'page_len' in 'set_query'?

I have read the documentation on overriding link queries by custom script, and I noticed that the load_query function accepts multiple arguments, such as doctype , txt , searchfield , start , page_len , and filters . However, when I tried to pass a value for the start argument, it did not change the search results and always returned 0.

Here is an example of the code I used to set the query:

frm.set_query('product', 'items', function () {
        return {
          query: 'ecommerce.controllers.queries.product_query',
          start: 3,
          filters: {
            has_variants: 0
          }
        }
      })

Hi,

This is the example for start parameter:

frm.set_query('product', 'items', function () {
  return {
    query: 'ecommerce.controllers.queries.product_query',
    filters: {
      has_variants: 0,
      // use the start parameter to skip the first 3 records
      // and return records starting from the 4th record
      // (assuming page_len is set to its default value of 20)
      idx: '>', 3,
    }
  }
})

Hope this will help you out.

Thank you.

Hi @VINOTH thank you for your response. but Is it possible to actually pass a value for the start argument like what about setting another argument, such as as_dict to True?

because from the doc there is an argument call as_dict

def product_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):

Hi,

The as_dict argument is set to True to return the query results as a list of dictionaries. This is useful when you need to access specific fields of the query result.

frappe.ui.form.on("Sales Order", {
  "customer": function(frm) {
    frm.set_query("item_code", "items", function() {
      return {
        query: "custom_queries.item_query",
        filters: {
          "customer": frm.doc.customer,
          "status": "Active"
        },
        as_dict: true // set the as_dict argument to true
      };
    });
  }
});

Hope this will help you out.

Thank you.