Hi There,
In my custom DocType, I have a field not mandatory, called inner_carton
.
Then I have other fields about inner carton such as length and weight. Also these fields are not mandatory.
If field inner_carton
is not empty, but it contains a value, I would that related fields becoming mandatory.
How can I implement this in DocType or through a custom script?
You can make a check in python that if inner_carton is not empty throw an error that the other dependent fields cannot be empty
I am not a programmer, I am a sysadmin.
Could be possible to share “a piece” of code so I can start do dig into and try to solve the problem?
Go to your custom doctype’s python file.
If it is empty that is no function exists then you need to create a validation function which executes everytime when we save or update a doctype record
def validate(self):
if self.inner_carton and not (self.length and self.weight):
frappe.throw(_(“length and weight fields are required”))
You can see example codes in existing python files of erpnext for example attendance.py