Anurag Tripathi
Mega Patron
Mega Patron

This blog covers the following:

  • Relating 2 or more tables to create a parent child relationship (One To Many)
  • Creating M2M Relationships (Many to Many)
  • Relationship through Query

 

Here are details on each:

 1)One to Many

This is the most common scenario that we see in the day to day work where we need to relate 2 tables to create a parent child relationship

To do this you just need to add a reference field on the child table, which is pointing to the parent.

When you have configured this you can see the related list on the parent when you go on configure -> related lists and it will be like:

Change Task -> Change Request

Common examples: Change Request field on Change Task, Request field on RITM

 

2)Many to Many

I find it most easy to explain this via an example: One User can be part of multiple groups and one Group can have multiple Users.

To create this you have to make an entry on the sys_m2m table. This creates a new table which wil have a reference field to both tables, hence one record can be related to multiple records on the other table and vice versa. The new table created will have m2m in its name.

On the form of sys_m2m you have to provide the ‘From Table’ and the ‘To Table’ and the Form will populate the other fields itself.

In this case on both the firm you can find this related list when you navigate to configure-> related list

Common examples: sys_user_has_license

 

3)Relationship Through Query

In my experience this is the most complicated of the three and also rarely used, but very powerful.

A typical scenario would be when you have to:

    • Connect 2 tables in a dynamic way.
    • Connect 2 tables that are not related by any field.
    • Both the above.

To create this relationship you must navigate to System Definition: Relationships

Again here you provide the details like Query From (Data will be fetched from here) and Applies to(Which form this relationship/related list will be added on)

If there is a complicated condition to choose the tables then you can click on ‘Advanced’ and apply script there too.

Common examples: Attachments

8 Comments