Frappe.ui.form.on Submit Form


I have this code:

frappe.ui.form.on("Item Log", { onload: function(frm) { $.ajax({ url: 'api/resource/Employee/?fields=["employee"]&filters=[["Employee","company_email","=","'+frm.doc.owner+'"]]', beforeSend: function() { cur_frm.set_value("usuario", __("Loading...")); }, success: function(res) { if ( > 0) { if([0].employee != undefined) { cur_frm.set_value("usuario",[0].employee); } else { msgprint(__("Employee name not found!")); itemLogReset(); } } else { msgprint(__("Employee not found!")); itemLogReset(); } } }); } });

I need call DocType List on Save.
frappe.set_route(“List”, “Item Log”);

How i implement this?

I try onSubmit (onsubmit), onSave (onsave) but not working.


I cannot properly gauge your requirement from your code but in case you need to call a python function from JS, then you would have to whitelist a method in your py module

def call_me():
msgprint(“call me”)

Then call from js

frappe.ui.form.on(“[doctype]”, “call_me”, function(frm) {{
method: “myapp.mymodule.call_me”,
callback: function(r) { };

Try after_save


Thanks again @KanchanChauhan !