Create parent child relationship automatically on related list

brostoff17
Tera Contributor

I have two tables I have created. One as the parent and one as the child.   When I click "New" on the related list of the child table, I want the parent record # to default into the child record that is created, similar to parent and child incidents.   How can I do this?

3 REPLIES 3

dvp
Mega Sage
Mega Sage

all you need to do is create a reference field on a child(B) table pointing to parent (A) table. Once field is created go to parent table and configure > related lists



and add the related list B -> A


Stephen Farrar
ServiceNow Employee
ServiceNow Employee

There is built in functionality for Many To Many tables which automatically create related lists that should do what you want.



To access it, open sys_m2m.list from your navigator, and create your relationship table from there.



You can find more information on sys_m2m here:


Create a many-to-many relationship


shloke04
Kilo Patron

Hi,



You can simply define a Reference field on the Child table say as "Parent" which is referring to the Parent Table on which you want this child Table to be added as a Related List.



1) For example, i have created a Custom table named as "Child Table" in which I have a created a field called Parent which is Referring to the Parent Table "ACL Testing" as shown below:



find_real_file.png



Note: Make sure that your Parent Table is extensible then only you would be able to select it while creating the field on the Child Table. If your parent table is not extensible then you need to Navigate to your Parent Table form and mark the "Extensible" checkbox as true as shown below:



find_real_file.png



For me "ACL Testing" is the name of the Parent Table shown in above screen shot.





2) Once the field has been Created you can Navigate to your Parent Table Form and add the above Table as your Related List as shown below:



find_real_file.png



find_real_file.png



3) Once the Related List has been Added you can click on the New button on your Child Table, and check for your parent Field which will contain the parent Number as required for you as shown below:



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke