I have a usecase where I need to have many-to-many mapping between 2 Doctypes as follows:
I have 2 Doctypes Plan & Control (It is many to many because many Controls can map to multiple Plans and vice versa)
I want to be able to create a Plan with(out) a Control and vice versa.
How can I implement this?
Note: I already explored using child table and creating intermediate table (with link types) but they dont fit my use case. With intermediate Doctypes I get an error that I am not sure how to fix as shown below.
For creatimg many to one fields in Frappe you had to use link fieldtype and in option select the doctype from which you had to join the other table/doctype.
Child tables with linking doctypes is indeed the correct way do many-to-many. I don’t know what’s going on with the error you’re showing, and it’s hard to say much more without context.
The Address and Contact interfaces on the Customer doctype uses a custom HTML field with doctype-specific javascript.
The actual data representation is managed by a child table with a linking doctype, like what I’m describing in my last post (the links child table in the Address or Contact doctype).
Thanks for that clarification, I found what I did wrong, I went to the child Table (Control Details) and set the Naming rule to be fieldName:[field], so that made the link field have the same value as the default primary key field of name, which obviously has a unique constraint in the DB.
For the sake of information for anyone else that is looking for a similar solution, these are my steps.
I did the following:
Created the Plan Doctype and the Control Doctype as standalone types
Then I created a Control Details is_child Doctype with a single link field to Control Doctype. Make sure that you dont change the default Settings for Naming.