Frappe.Call and

Hi All,

I have been using and (on top or beginning of file) to get data from doctypes … because I need to retrieve a record based on the status=active or not …
when using those call I have to send ALERT msg to user in order to have the RETURN from the CALL otherwise it takes more time to get the answer of the method called.
My question is why does it takes time to return the result for instance of the method (py) (select name from XXXX where status=active). when the ALERT msg is sent the register XX receives the result and while on the PY Print you see the result is instantaneity.
Am I using the wrong function to call or retrieve a record from a doctype based on filter on JS?

Can you post your code here. It will help to better understand your usecase.

@netchampfaris here is my code
from JS
// Copyright (c) 2016, Helio de Jesus and contributors
// For license information, please see license.txt


frappe.ui.form.on(‘BAR_RESTAURANTE’, {
onload: function(frm) {{
filters: {
status_caixa:[‘in’, ‘Aberto, Em Curso’]
fields: [“status_caixa”]
callback: function(r) {
if (r.message) {
$.each(r.message, function(i,d) {
console.log(i.toString() + ": " + d.status_caixa);
caixaopen = d.status_caixa;
frappe.ui.form.on(‘BAR_RESTAURANTE’, {
refresh: function(frm) {
alert(“Abrir o Caixa”)

by adding an Alert on the Refresh I can get the Result of the I have made for both and the call on the Load…

def caixa_aberto():
return frappe.get_list(“CAIXA_Registadora”,filters={‘status_caixa’:[‘in’, ‘Aberto, Em Curso’]},fields=[‘name’,‘status_caixa’])

def check_caixa_aberto():

if (frappe.db.sql("""select name from `tabCAIXA_Registadora` WHERE status_caixa ='Aberto' """, as_dict=False)) != ():
	return frappe.db.sql("""select name from `tabCAIXA_Registadora` WHERE status_caixa ='Aberto' """, as_dict=False)
elif (frappe.db.sql("""select name from `tabCAIXA_Registadora` WHERE status_caixa ='Em Curso' """, as_dict=False)) != ():
	return frappe.db.sql("""select name from `tabCAIXA_Registadora` WHERE status_caixa ='Em Curso' """, as_dict=False)

If I don’t alert the variables take time to get values …unless I unload I go back to the grid and open again the form/doctype …
I have tried Fetch and does not load the values I need …
Wonder why cannot call frappe.get_list from JS as this allows filters!!!

When you use or you are using ajax to get results from server which will take time, it is an async operation.

You need to pass a callback, and then use the result. In your case,{
    args: {"start":"none" },
    callback: function(r) {
      cx_open = r.message;

Can I still call the from the top of the file or should it be
included inside the Onload or Setup or init function?

It should be inside the onload.
Also, use frm instead of cur_frm, since it will be deprecated.

OK. But even adding the on Onload I still can’t get the results
during the Onload making me move or change my code to be checked during the
For instance the reason why I call is to check if the value is opened so
the other steps are done… If the result does not show up on time the user
will be able to insert a new record (double)…