AgileApps Support Wiki Pre Release

Difference between revisions of "Junction Object"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
(18 intermediate revisions by the same user not shown)
Line 10: Line 10:
You can use the platform's [[Object_Relationships#Using the Wizard to Create a Many to Many Relationship|Wizard]] to create a Many to Many relationship. In that case, the Junction Object is created for you, behind the scenes.
You can use the platform's [[Object_Relationships#Using the Wizard to Create a Many to Many Relationship|Wizard]] to create a Many to Many relationship. In that case, the Junction Object is created for you, behind the scenes.


You can also create a junction object manually (a technique you'll need to know if you creating relationships programmatically):
You can also create a junction object manually (a technique you'll need to know if you create relationships programmatically):
# Create the object that will become the junction.<br>For example: Orders_Tags.
# Create the object that will become the junction. For example: Orders_Tags.
# In that object, add a [[Lookup]] to each of the target objects.<br>For example, <tt>related_to_Orders</tt> and <tt>related_to_Tags</tt>
# In that object, add a [[Lookup]] to each of the target objects. For example, <tt>related_to_Orders</tt> and <tt>related_to_Tags</tt>
# Customize one of the target objects.<br>For example, Orders.
# Customize one of the target objects. For example: Orders.
# Go to the [[Relationships]] tab.
# Go to [[Object Relationships]].
# Edit the Orders_Tags relationship.
# Edit the Orders_Tags relationship.
# Select the '''Junction''' radio button to make the relationship many-to-many.
# Select the '''Junction''' radio button to make the relationship many-to-many.
# Specify the object at the other end of the Junction, and the field to use.<br>(Typically, the default ''ID'' field is perfect.)
# Specify the object at the other end of the Junction, and the field to use (<tt>related_to_Tags</tt>).


That process of creating a relationship adds the second Lookup to the middle object (from Orders_Tags to Tags, in this example), and identifies Orders_Tags as a "junction" object. Because the platform knows it is a junction object, the user sees records from the end-point object (Tags) when doing a look up. Otherwise, the user would see records from Orders_Tags.
The process of creating a relationship identifies Orders_Tags as a "junction" object. Because the platform knows it is a junction object, it displays records from the end-point object (Tags) when the user does a look up. (Otherwise, the user would see records from Orders_Tags.)
 
===Record Filtering in a Junction Object Lookup===
 
:#Under Record Filtering, make selections for the Sort by field and the Sort Order.
:#Under Record Filtering section, filters can be configured in Filtering Criteria.
 
 
{{Note| <br>
:* Filtering Criteria value supports static values only. For example, 123, 1, 2, 3, Created By equals '56ca4a5cdc1d49a9ba044cb28ea7f021'.
:* '''Post Selection JavaScript''' is not supported with Junction Objects.
 
:[[File:Junc obj record filter3.png]] }}
<noinclude>
<noinclude>


[[Category:Glossary]]
[[Category:Glossary]]
</noinclude>
</noinclude>

Latest revision as of 06:34, 5 August 2021

In a relational database, a Lookup field in a source object can point to exactly one record in a target object. That capability creates one-to-many and many-to-one relationships. (For example, many Orders point to a single Customer. That's many-to-one. Looking at it the other way around, a Customer has multiple Orders. That's one-to-many.)

But sometimes, you need a many-to-many relationship. (For example, an Order can have multiple tags, and each tag can clearly apply to multiple orders.) You accomplish that goal with a junction object:

JunctionObject-80percent.png

Here, the junction object is Orders_Tags. Every record in it points to exactly one Order and one Tag. But several records that point to the same Order can each point to a different Tag. Similarly, several records that point to the same Tag can each point to a different Order. In that way, a many-to-many (N:M) relationship is established.

Create a Junction Object Manually

You can use the platform's Wizard to create a Many to Many relationship. In that case, the Junction Object is created for you, behind the scenes.

You can also create a junction object manually (a technique you'll need to know if you create relationships programmatically):

  1. Create the object that will become the junction. For example: Orders_Tags.
  2. In that object, add a Lookup to each of the target objects. For example, related_to_Orders and related_to_Tags
  3. Customize one of the target objects. For example: Orders.
  4. Go to Object Relationships.
  5. Edit the Orders_Tags relationship.
  6. Select the Junction radio button to make the relationship many-to-many.
  7. Specify the object at the other end of the Junction, and the field to use (related_to_Tags).

The process of creating a relationship identifies Orders_Tags as a "junction" object. Because the platform knows it is a junction object, it displays records from the end-point object (Tags) when the user does a look up. (Otherwise, the user would see records from Orders_Tags.)

Record Filtering in a Junction Object Lookup

  1. Under Record Filtering, make selections for the Sort by field and the Sort Order.
  2. Under Record Filtering section, filters can be configured in Filtering Criteria.


Notepad.png

Note:

  • Filtering Criteria value supports static values only. For example, 123, 1, 2, 3, Created By equals '56ca4a5cdc1d49a9ba044cb28ea7f021'.
  • Post Selection JavaScript is not supported with Junction Objects.
Junc obj record filter3.png