Hello everyone,
I have a slight problem with a custom script. I am creating this script for my customer form.
Just to get a bit of back-ground, I am running an image of ERPnext on my virtual machine.
Here is the code:
//Code starts here
cur_frm.cscript.custom_validate = function(doc){
//check the length of the owners_id_number field (that field is of type 'data')
if (len(doc.owners_id_number) < 13) {
validated = false;
webnotes.msgprint ("The ID number cannot be less than 13 digits long");
}
}
//code ends here.
When I click the save button nothing happens, the form is not saved and the data in the fields don't disappear - nothing happens.
I am missing something?
Thank you for your help.
Kat.
–
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.
- Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
- 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.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hello, Kat!
len()
is a python
native function, and you script are in javascript
, in javascript
the way to check the length of an object is with length
property.
try this code:
if (doc.owners_id_number && (doc.owners_id_number.length < 13)){
.... you code here
}
2013/12/18 Kat
<py...@gmail.com>
Hello everyone,
I have a slight problem with a custom script. I am creating this script for my customer form.
Just to get a bit of back-ground, I am running an image of ERPnext on my virtual machine.
Here is the code:
//Code starts here
cur_frm.cscript.custom_validate = function(doc){
//check the length of the owners_id_number field (that field is of type 'data')
if (len(doc.owners_id_number) < 13) {
validated = false;
webnotes.msgprint ("The ID number cannot be less than 13 digits long");
}
}
//code ends here.
When I click the save button nothing happens, the form is not saved and the data in the fields don't disappear - nothing happens.
I am missing something?
Thank you for your help.
Kat.
–
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.
- Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
- 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.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Maxwell Morais
–
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.
- Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
- 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.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thank you Maxwell.
Using the JavaScript length property works well.
Thanks.
On Wednesday, December 18, 2013 4:25:22 PM UTC+2, Maxwell wrote:
Hello, Kat!
len()
is a python
native function, and you script are in javascript
, in javascript
the way to check the length of an object is with length
property.
try this code:
if (doc.owners_id_number && (doc.owners_id_number.length < 13)){
.... you code here
}
2013/12/18 Kat
<py...@gmail.com>
Hello everyone,
I have a slight problem with a custom script. I am creating this script for my customer form.
Just to get a bit of back-ground, I am running an image of ERPnext on my virtual machine.
Here is the code:
//Code starts here
cur_frm.cscript.custom_validate = function(doc){
//check the length of the owners_id_number field (that field is of type 'data')
if (len(doc.owners_id_number) < 13) {
validated = false;
webnotes.msgprint ("The ID number cannot be less than 13 digits long");
}
}
//code ends here.
When I click the save button nothing happens, the form is not saved and the data in the fields don't disappear - nothing happens.
I am missing something?
Thank you for your help.
Kat.
–
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.
- Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
- 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.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Maxwell Morais
–
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.
- Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
- 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.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.