Suppose I have three DocTypes:
Controller I have three fields:
- a check box :
- a table link to
- a table link to
is_a_widget = 1 then selecting a
Widget is mandatory and
Foobar is disabled
is_a_widget = 0 then selecting a
Foobar is mandatory and
Widget is disabled
is_a_widget check mark and only one of the fields should be visible. All should be read-only.
Is this even possible?
Everything I try seems to get me the error:
Invalid Mandatory Depends On condition
Could we see the DocType definition (json file)?
"depends_on": "eval: doc.is_a_widget == false", (or true, depending on where this is going)
I’m assuming you have a line similar to this one above on both the
Foobar table fields?
Ironically, I just ran into something similar. The
mandatory means the field is occupied, no matter what.
My scrappy solution was to not make the fields mandatory and use
frm.set_df_property('myfield', 'reqd', 0); // I'm assuming 'reqd' means "required".
Along with a
frappe.throw on form validation to show an error, this is the best I could do. Keep in mind this only works if editing documents through the normal Frappe DocForm.
I’m still experimenting.
(My original error was thinking the condition was described in SQL, so I was using single “=”. Your example made me wake up. Thanks for that.)
This is weird. So ERPNext provides a great big expandable text box “Mandatory Depends On” so you can enter very detailed conditions that will never have any effect 'coz the field will always be mandatory anyway? Reminds me of Kurt Vonnegut’s troop ship to Neptune, where the cockpit has only a big red STOP button … so the troops “feel” like they’re still in control.
I was thinking that that would be the case if the database table attribute was defined as “NOT NULL”, but I checked and it isn’t.
Oh for f’sake!!!
My learning path for ERPNext has simply taken me from bug to the next bug to another bug. Wasting time and more time and yet more time. It’s a mine field! It really is!
I didn’t even know there was a Mandatory Depends On field. I’m still developing on v12
OH! Well that clarifies things … a little bit!
I’m working on commissioning my first ERP site, and reckon by going for Ubuntu 20.04 LTS and ERPNext v13 I ought to get a couple of years run before having to face upgrading. But, then the down-side of a brand new platform is the lack of guard rails, right?.
I’ll be using :