Frappe.ui.form.on Submit Form

Hello,

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 (res.data.length > 0) { if(res.data[0].employee != undefined) { cur_frm.set_value("usuario", res.data[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.

Thanks

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

@frappe.whitelist()
def call_me():
msgprint(“call me”)

Then call from js

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

Try after_save

3 Likes

Thanks again @KanchanChauhan !