How to Restrict User to only have one row per child table in a doctype

Is there a way to restrict rows to only one row per entry in a child table that is used in a different doctype where the child tables are doctypes?

I am not sure I understood your requirement but did you consider having the child table as Single?

Didn’t work. The child table itself has multiple fields of information and the “single” option is greyed out.

To rephrase my question:
I have a doctype that accepts entries through multiple child tables. This way the information is not necessarily in one place and I can apply permissions on the child tables independently or reuse them in other doctypes I have created. However, I want to restrict the entry into each child table in the doctype to only one row of information per child table. Currently i can insert multiple information into the child table by clicking “add row”. I want to have that disabled or restricted or whatever else allows me achieve the same result.

You can write validation rules via hooks, basically check for length and throw an error when someone tries to create a second row. Hook events script a good discussion on this topic. It has some good example on how to use custom validations.

1 Like

Is there a way to restrict to one row for child table in setup, without custom scripts or code ?
Thanks