ERPNext form requires reload when method calls


I am calling one of my Python method on on_submit of delivery note doctype and from that method, I am assigning value to my custom field using frappe.db.set_value.

Now my concern is the value which I assign from the method, it is not reflected in the field. But when I reload my form then and then it stores that value in the field.

It requires every time to reload the form of my current record to store the value in a field.

So, What is the reason behind that?

Please share your code.

frappe.db.set_value(“Delivery Note”,, ‘tracking_reference’, track_numbers[0])

In :- my current record name(id)
tracking_reference is my custom field
track_numbers[0] is the value which i want to store in my field.

Yes, this is an intended behaviour. When values in database are changed directly (using frappe.db.set_value), the form doesn’t know about the change. Hence, you need to manually refresh the form


But there is not any other way to solve this?

Probably you can refresh field in callback

How can i do this?

Use in javascript for onsubmit trigger

I find out the solution for my problem to reload the form from the on_submit button.

frappe.ui.form.on(‘Delivery Note’, {
on_submit: function(frm) {