import frappe from frappe import _ from frappe.model.document import Document class StockDemo(Document): def on_submit(self): serial_no = self.serial_no return serial_no
There is a field called Serial No, which is mandatory. This field is not suggested and not working. What might be the mistake. I have reloaded system, even though no changes.
By not suggested, do you mean on submitting it throws an error like “serial no is undefined” or something?
The function doesn’t do anything right now. Return doesn’t do anything for event controllers like on_submit.
yes, nothing happens. But some fields are working like item_group, brand
Any other ways to access?
I don’t understand what you require.
The serial no field is mandatory but you can submit the form even when it is blank?
You want to set a value to the serial no field on submitting the form?
In this function “on submit” of form, I should get the serial_no which is entered in the form. But i am not getting the value.
Events such as on_validate triggers before before_save, and on_submit only triggers after the doc is considered submitted, in which case no further rendering will take place.
Are you saying the serial no is not visible in the console?
Are you calling this on_submit function from the client side?
I mean, the function doesn’t do anything!
You are just saving the field’s value to a variable. Returning that value will not give you any output as far as I know.
You could try the following code in the on_submit function
def on_submit(self): frappe.log_error("Serial Number", self.serial_no)
Then go to the error log doctype, there you will see the value captured in the serial_no field.