-
This is for a validation of form that has already been submitted
-
Problem is a submitted form does not raise after_save event.
-
We want to reload the page after submitted document is updated but error was thrown using frappe.throw.
-
Due to no events raised after frappe.throw, we’re wondering how we can achieve this.
@frappe.whitelist() def user_validation(self,method): se= frappe.get_roles(frappe.session.user) Currentuser = frappe.session.user officer_email = frappe.db.sql("""select * from `tabProperty Handover Officers` where employee_full_name=%s""",(self.officer_name),as_dict=True) if(validate(self)==True): return True elif(self.officer_name!="" and officer_email[0].user_id!=Currentuser): frappe.throw("Can't update the case, it can only be updated by associated officer.") HERE WE WANT TO REFRESH PAGE AFTER THROW ERROR else: return True
If you want to validate data after doc submitted then use
following trigger before_update_after_submit or on_update_after_submit or on_update
and for reload doc use self.reload()
its running on hooks on on_update_after_submit, when frappe.throw runs it stops the code and form will not be reloaded… how it can be done then ??
self.reload() is not working
I think than you have to use try except in except you have to handle your issue
and if self.relaod() not working than you have to fetch doc object using doc= frappe.get_doc(“your doc”, name) and after that use doc.reload()
if we do frappe.throw() then it will automatically not execute the code
Do the doc reload process before frappe.throw
we do doc reload by getting frappe.get_doc ??
doc= frappe.get_doc(“Customer”, “xyz”)
doc.reload()
Try this and check whether this working or not
still reload is not working… if we do without frappe.throw, it will submit the document and reload even without doc.reload() but when we use frappe.throw() and use doc.reload()… it will stop the code but wont reload
have you tried before frappe.throw?
yes but still it wasn’t working
hi do you find the solution?