Mandatory Fields based on other fields

Hi,

I want to make either of the 2 fields as mandatory in a Communication form but somehow the system is not picking the custom script and even if both the CUstomer and Lead are empty the code is making the communication. Kindly let me know if there is any error in the code that I am unable to find, the code is below:

cur_frm.cscript.custom_validate = function(doc) {
    if(doc.customer ===“” || doc.lead ===“”) {
        alert(“Either Lead or Customer should be filled in Communication”);
        system.exit ();
    }
}



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.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/vMwC_rneYBgJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

use

if(!doc.customer || !doc.lead)

values can also be "null" which is different from ""


On 12-Apr-2013, at 2:29 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I want to make either of the 2 fields as mandatory in a Communication form but somehow the system is not picking the custom script and even if both the CUstomer and Lead are empty the code is making the communication. Kindly let me know if there is any error in the code that I am unable to find, the code is below:

cur_frm.cscript.custom_validate = function(doc) {
    if(doc.customer ==="" || doc.lead ==="") {
        alert("Either Lead or Customer should be filled in Communication");
        system.exit ();
    }
}



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/vMwC_rneYBgJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




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.

To post to this group, send email to er...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi Aditya,

Use this script: http://pastebin.com/jFNsPCF9

Thanks,
Anand.

On 12-Apr-2013, at 2:29 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I want to make either of the 2 fields as mandatory in a Communication form but somehow the system is not picking the custom script and even if both the CUstomer and Lead are empty the code is making the communication. Kindly let me know if there is any error in the code that I am unable to find, the code is below:

cur_frm.cscript.custom_validate = function(doc) {
    if(doc.customer ==="" || doc.lead ==="") {
        alert("Either Lead or Customer should be filled in Communication");
        system.exit ();
    }
}



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.

To post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/vMwC_rneYBgJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




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.

To post to this group, send email to er...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.