Newer Version Available
Try It Out: Add Fields to the Job Posting Object
To turn the Job Posting object into the junction object that relates the Position and Employment Website objects, we'll need to add two master-detail relationship fields. The first master-detail relationship will be the primary relationship. The detail and edit pages of our junction object (Job Posting) will use the color and any associated icon of the primary master object (Position). In addition, the junction object records will inherit the value of the Owner field and sharing settings from their associated primary master record.
- From Setup, enter Objects in the Quick Find box, then select Objects.
- Click Job Posting.
- In the Custom Fields & Relationships related list, click New.
- Select Master-Detail Relationship, and click Next.
- In the Related To drop-down list, choose Position, and click Next.
- In the Field Label text box, enter Position. When you move your cursor, the Field Name text box should be automatically populated with Position as well.
- Accept the remaining defaults, and click Next until you reach the final step of the wizard.
Here, we are given the chance to add the Job Postings related list to the Position object page layout. Instead of displaying information about related job postings, we want this list to show all the employment websites where this position is posted. So let's add the Job Posting related list, but rename it Employment Websites.
- In the Related List Label text box, enter Employment Websites.
- Accept the other defaults and click Save & New.
We're halfway through the creation of our many-to-many relationship. The next step is to create a second master-detail relationship on the Job Posting object to link it with the Employment Website object.
The second master-detail relationship creates a secondary relationship. Unlike the primary relationship, the secondary relationship has no affect on the look and feel of the junction object. However, just as in the primary relationship, the sharing settings of the master record in the secondary relationship also affect who can access the junction record, and deleting a record of the secondary master object will automatically delete its associated junction object records. So in our app, if you delete an employment website record, all of its associated job posting records are deleted as well, even if the position is open.
- Select Master-Detail Relationship, and click Next.
- In the Related To drop-down list, choose Employment Website, and click Next.
- In the Field Label text box, enter Employment Website. When you move your cursor, the Field Name text box should be automatically populated with Employment_Website as well.
- Click Next. Because we are creating a master-detail relationship, these settings cannot be changed.
- Click Next. These settings cannot be changed as well.
- Click Next to view the final step of the wizard.
This time we are given the chance to add the Job Postings related list to Employment Website object page layout. We'll eventually configure this related list to show all the positions that are posted on this website, so let's add the Job Postings related list but rename it Positions.
- In the Related List Label text box, enter Positions.
- Accept the other defaults and click Save.
Now our many-to-many relationship is complete! Or is it?
While we have an Employment Websites related list on the Position object and a Positions related list on the Employment Websites object, both related lists still display job posting records. This won't do.
In order to achieve our goal of listing multiple positions on an employment website record and multiple employment websites on a position record, we need to customize the fields in these related lists.