I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
version 3: cur_frm.cscript.custom_on_submit = function(doc) { var msg = wn._("Some validation error"); msgprint(msg) throw(msg); }
with version 2 I see below error in console. [10:49:34.180] "----- error in client script -----" [10:49:34.180] "method: on_submit" [10:49:34.180] "Please attach atleast 1 file" [10:49:34.180] "error message: undefined" [10:49:34.180] http://23.23.151.62:6625/js/all-app.min.js :: _f.Frm.prototype.log_error :: 2223 http://23.23.151.62:6625/js/all-app.min.js :: _f.Frm.prototype.runclientscript :: 2217 http://23.23.151.62:6625/js/all-app.min.js :: _f.Frm.prototype.savesubmit/</< :: 2237 http://23.23.151.62:6625/js/all-app.min.js :: _f.Frm.prototype.save/< :: 2236 http://23.23.151.62:6625/js/all-app.min.js :: wn.model.DocList<._call/<.callback :: 622 http://23.23.151.62:6625/js/all-app.min.js :: wn.request.call/ajax_args.success :: 298 http://23.23.151.62:6625/lib/js/lib/jquery/jquery.min.js :: p.Callbacks/k :: 2 http://23.23.151.62:6625/lib/js/lib/jquery/jquery.min.js :: p.Callbacks/l.fireWith :: 2 http://23.23.151.62:6625/lib/js/lib/jquery/jquery.min.js :: y :: 2 http://23.23.151.62:6625/lib/js/lib/jquery/jquery.min.js :: .send/d :: 2 [10:49:34.180] "----- end of error message -----"
Thanks for your help.
Kind regards, MP
–
Note:
If you are posting an issue,
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
On Wednesday, 4 September 2013 11:02:55 UTC+1, MP wrote:
Hi There,
I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
On Wednesday, 4 September 2013 11:02:55 UTC+1, MP wrote:
Hi There,
I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
On Wednesday, 4 September 2013 11:02:55 UTC+1, MP wrote:
Hi There,
I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Much appreciated. Could you please let me know which commit this is part of. We are still on old version, I have will have to manually apply these changes. Also which of the 3 method is valid (i.e. Validated=false, return false or throw(msg))?
On Wednesday, 4 September 2013 13:32:20 UTC+1, rushabh wrote:
Just pushed.
You can add your validation in custom_before_submit
On 04-Sep-2013, at 5:56 PM, Rushabh Mehta <rm...@gmail.com> wrote:
Mayur,
on_submit is called after submit
You should write your logic in validate, but there you cannot know if the call is for Save or Submit...
Please raise PR - I will fix this and add a custom_before_submit method.
On Wednesday, 4 September 2013 11:02:55 UTC+1, MP wrote:
Hi There,
I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
Thanks once again for making this change so quick.
Kind regards, MP
On Wednesday, 4 September 2013 14:14:30 UTC+1, MP wrote:
Thanks Rushabh.
Much appreciated. Could you please let me know which commit this is part of. We are still on old version, I have will have to manually apply these changes. Also which of the 3 method is valid (i.e. Validated=false, return false or throw(msg))?
On Wednesday, 4 September 2013 13:32:20 UTC+1, rushabh wrote:
Just pushed.
You can add your validation in custom_before_submit
On 04-Sep-2013, at 5:56 PM, Rushabh Mehta <rm...@gmail.com> wrote:
Mayur,
on_submit is called after submit
You should write your logic in validate, but there you cannot know if the call is for Save or Submit...
Please raise PR - I will fix this and add a custom_before_submit method.
On Wednesday, 4 September 2013 11:02:55 UTC+1, MP wrote:
Hi There,
I need to do some custom validations on client end when a user clicks on Submit button. If the validations fails on client side, I want system to display a message to user and don't want system continue with submitting it the service side. How do you stop system from submitting a document? To test it out, I have written below script but it doesn't seem to stop the client from sending the submit request to server.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
This is a useful function, but doesn’t quiet address my use case. I need to take a user input on submit, validate the input and based on the validation, decide to submit or cancel submission. The custom_before_submit doesnt wait for the user input to be provided - before that it finishes execution. I can stop submission of document with ‘validated=false’, but then dont know how to submit the document once I receive the user input. Any help?