--- title: "Salesforce Junction Object" slug: "salesforce-relationships-to-other-objects-data" description: "Learn how to relate ScreenMeet Live Session records to Salesforce objects using junction objects and Apex triggers for seamless integration." tags: ["trigger", "salesforce", "apex", "junction", "many-to-many", "relationship"] updated: 2026-06-25T14:21:38Z published: 2026-06-25T14:21:38Z canonical: "docs.screenmeet.com/salesforce-relationships-to-other-objects-data" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.screenmeet.com/llms.txt > Use this file to discover all available pages before exploring further. # Relationships to Other Objects: Data ## Relationships to Other Objects: Data ### Overview This guide explains how to relate ScreenMeet Live Session records to any standard or custom Salesforce object, such as Case, Opportunity, or a custom record type. When configured, a related list on the parent record will display all ScreenMeet sessions that were launched from it. The approach uses a junction object to store the relationship between the parent record and the Live Session record. An Apex Trigger on `screenmeet__Live_Session__c` fires on insert and creates the junction record automatically. You can support multiple parent object types in a single trigger by adding a branch for each. Advanced TopicThis guide assumes familiarity with Salesforce Object Manager, Apex Triggers, and Permission Sets. Foundational knowledge of relational data models is recommended before proceeding. --- ### Prerequisites - System Administrator access to the Salesforce org - ScreenMeet managed package installed and configured - The ScreenMeet widget added to the target object's page layout - Knowledge of which Salesforce object you are linking to ScreenMeet sessions (for example, `Case`, `Opportunity`) --- ### Step 1: Create the Junction Object Create one junction object for each Salesforce object you want to relate to ScreenMeet sessions. Repeat this step for each object type. 1. Sign in as a System Administrator and open **Setup**. 2. Enter **Object Manager** in Quick Find, then open **Object Manager**. 3. Click **Create** in the top-right corner and choose **Custom Object**. 4. Fill in the following fields, substituting your object name where indicated: | Field | Example Value (Case) | Example Value (Opportunity) | | --- | --- | --- | | Label | `ScreenMeet Case Session` | `ScreenMeet Opportunity Session` | | Plural Label | `ScreenMeet Case Sessions` | `ScreenMeet Opportunity Sessions` | | Object Name | `ScreenMeet_Case_Session` | `ScreenMeet_Opportunity_Session` | | Record Name | `Case Session` | `Opportunity Session` | | Data Type | Text | Text | 1. Click **Save**. Note the API name assigned to your new object (for example, `ScreenMeet_Opportunity_Session__c`). You will need this in the trigger code. --- ### Step 2: Add Lookup Fields to the Junction Object Add two lookup fields to the junction object: one pointing to your parent object (for example, Opportunity) and one pointing to ScreenMeet Live Session. Use Lookup, Not Master-Detail, for ScreenMeet Live SessionThe `screenmeet__Live_Session__c` object is part of a managed package. Salesforce does not allow Master-Detail relationships to be created against managed objects from outside the package. Select **Lookup Relationship** for the ScreenMeet Live Session field or the field creation will fail. From your new junction object, open **Fields & Relationships** and complete the following: #### Field 1: Parent Object Lookup 1. Click **New**. 2. Select **Lookup Relationship** (or **Master-Detail Relationship** if preferred and supported for your object), then click **Next**. 3. From **Related To**, select your parent object (for example, **Opportunity**), then click **Next**. 4. Set the Field Label and Field Name to match the object name (for example, `Opportunity`). 5. Click through the remaining screens and click **Save & New**. #### Field 2: ScreenMeet Live Session Lookup 1. Select **Lookup Relationship**, then click **Next**. 2. From **Related To**, select **ScreenMeet Live Session**, then click **Next**. 3. Set the Field Label to `ScreenMeet Live Session` and the Field Name to `ScreenMeet_Live_Session`. 4. Click through the remaining screens and click **Save**. Verify Field API Names Before Writing Trigger CodeAfter saving, go to **Fields & Relationships** on the junction object and note the exact API names for both fields. The Field Name you enter during setup becomes the API name with `__c` appended. Use these exact values in the trigger code in Step 3. --- ### Step 3: Identify the Parent Object Type Value The trigger uses the `screenmeet__parentObjectType__c` field on the Live Session record to determine which junction object to write to. You must know the exact value this field contains when a session is started from your target object. To find the value, start a test ScreenMeet session from the target object record, then open the resulting Live Session record in Salesforce and check the `screenmeet__parentObjectType__c` field. Common values are `case` and `opportunity` (lowercase). Value Must Match ExactlyThe string comparison in the trigger is case-sensitive. If the field contains `opportunity` and the trigger checks for `Opportunity`, the branch will not fire and no junction record will be created. --- ### Step 4: Add the Apex Trigger There can only be one trigger per object event on `screenmeet__Live_Session__c`. If you are adding support for a second object type and a trigger already exists, edit the existing trigger to add a new branch rather than creating a new one. 1. Open **Object Manager**. 2. Find **ScreenMeet Live Session** (API name: `screenmeet__Live_Session__c`) and open it. 3. Click **Triggers**, then click **New** (or open the existing trigger to edit it). 4. Paste or update the trigger code below, adding or adjusting branches for each object type you are supporting. 5. Click **Save**. The following example supports both Case and Opportunity. Substitute the correct junction object API names, field API names, and `parentObjectType__c` values for your implementation. Namespace Prefix on Managed Junction ObjectsIf your Case junction object was created by the ScreenMeet managed package installer, its API name and field names will include the `screenmeet__` namespace prefix (for example, `screenmeet__ScreenMeet_Case_Session__c`). Junction objects you create manually will not have a prefix. Check Object Manager to confirm the correct API names before saving the trigger. ```apex trigger Live_Link_Object_Trigger on screenmeet__Live_Session__c (after insert) { if (Trigger.isInsert) { for (screenmeet__Live_Session__c newSessionRow : Trigger.new) { // Case branch - update object and field API names if your junction object // was installed by the managed package (e.g. screenmeet__ScreenMeet_Case_Session__c) if (newSessionRow.screenmeet__parentObjectType__c == 'case') { screenmeet__ScreenMeet_Case_Session__c junction = new screenmeet__ScreenMeet_Case_Session__c( screenmeet__ScreenMeet_Live_Session__c = newSessionRow.Id, screenmeet__Case__c = newSessionRow.screenmeet__parentObjectId__c, Name = newSessionRow.screenmeet__session_type__c + ': ' + newSessionRow.screenmeet__Session_Id__c ); insert junction; // Opportunity branch - substitute your junction object and field API names } else if (newSessionRow.screenmeet__parentObjectType__c == 'opportunity') { ScreenMeet_Opportunity_Session__c junction = new ScreenMeet_Opportunity_Session__c( ScreenMeet_Live_Session__c = newSessionRow.Id, Opportunity__c = newSessionRow.screenmeet__parentObjectId__c, Name = newSessionRow.screenmeet__session_type__c + ': ' + newSessionRow.screenmeet__Session_Id__c ); insert junction; // Add additional else if branches here for other object types } } } } ``` --- ### Step 5: Set Permissions on the Junction Object Repeat the following for each junction object you created. Two layers of access must be configured: the service account needs Create access to write junction records, and agents need Read access to view the related list. #### Service Account Permissions 1. Go to **Setup** and open **Permission Sets**. 2. Open the permission set assigned to the ScreenMeet service account. If you are unsure which one, go to the service account user record and check **Permission Set Assignments**. 3. Click **Object Settings** and find the junction object. 4. Click **Edit** and enable **Read**, **Create**, **Edit**, and all **Field Permissions**. 5. Click **Save**. Missing Service Account Permissions Will Break Session CreationIf the service account does not have Create access on the junction object, the trigger will throw a `System.SecurityException: Access to entity denied` error when a session is started, causing the session launch to fail for the agent. #### Agent Read Access The ScreenMeet Agent permission set is part of the managed package and cannot be edited. Instead, configure object-level Read access at the profile level and open up record visibility org-wide. **Set Organization-Wide Default to Public Read Only:** 1. Go to **Setup** and open **Sharing Settings**. 2. Scroll to your junction object in the Organization-Wide Defaults table and click **Edit**. 3. Set the default access to **Public Read Only** and click **Save**. **Grant Read access via Profile:** 1. Go to **Setup** and open **Profiles**. 2. Open the profile assigned to your ScreenMeet agents. 3. Find the junction object under **Custom Object Permissions**, enable **Read**, and click **Save**. 4. Repeat for any other profiles that require visibility into ScreenMeet session related lists. Two Layers of Access RequiredSalesforce enforces object-level permissions and record-level sharing separately. The OWD setting controls which records a user can see, but the profile must still grant Read access to the object itself before any records are visible. Both must be configured. --- ### Step 6: Configure the Page Layout 1. Navigate to a record of the target object type (for example, an Opportunity). 2. Click the **Gear** icon in the top right and select **Edit Object**. 3. Click **Page Layouts** and open the layout you want to update. 4. Scroll to the **Related Lists** section. If the junction object's related list is not already on the layout, drag it in from the palette. 5. Click the **Wrench** icon on the related list and add the following columns: - Junction Object: Record Name (for example, **Opportunity Session**) - ScreenMeet Live Session: **Live Session** (provides the link to the session record) - ScreenMeet Live Session: **Status** - ScreenMeet Live Session: **Created Date** 1. Set **Sort By** to ScreenMeet Live Session: Created Date and **Order** to Descending. 2. Click **OK**, then click **Save**. Duplicate Related ListsIf you see two related lists for the same junction object on the page layout, check **Fields & Relationships** on the junction object for duplicate lookup fields pointing to the same parent object. Delete the extra field and the corresponding related list will be removed automatically. --- ## Related - [Adding the ScreenMeet Component to Object Records](/salesforce-adding-the-screenmeet-component-to-object-records.md) - [Page Layouts for Related Objects](/salesforce-junciton-page-layouts.md)