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.
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.
- Sign in as a System Administrator and open Setup.
- Enter Object Manager in Quick Find, then open Object Manager.
- Click Create in the top-right corner and choose Custom Object.
- 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 |
- 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.
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
- Click New.
- Select Lookup Relationship (or Master-Detail Relationship if preferred and supported for your object), then click Next.
- From Related To, select your parent object (for example, Opportunity), then click Next.
- Set the Field Label and Field Name to match the object name (for example,
Opportunity). - Click through the remaining screens and click Save & New.
Field 2: ScreenMeet Live Session Lookup
- Select Lookup Relationship, then click Next.
- From Related To, select ScreenMeet Live Session, then click Next.
- Set the Field Label to
ScreenMeet Live Sessionand the Field Name toScreenMeet_Live_Session. - Click through the remaining screens and click Save.
__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).
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.
- Open Object Manager.
- Find ScreenMeet Live Session (API name:
screenmeet__Live_Session__c) and open it. - Click Triggers, then click New (or open the existing trigger to edit it).
- Paste or update the trigger code below, adding or adjusting branches for each object type you are supporting.
- 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.
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.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
- Go to Setup and open Permission Sets.
- 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.
- Click Object Settings and find the junction object.
- Click Edit and enable Read, Create, Edit, and all Field Permissions.
- Click Save.
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:
- Go to Setup and open Sharing Settings.
- Scroll to your junction object in the Organization-Wide Defaults table and click Edit.
- Set the default access to Public Read Only and click Save.
Grant Read access via Profile:
- Go to Setup and open Profiles.
- Open the profile assigned to your ScreenMeet agents.
- Find the junction object under Custom Object Permissions, enable Read, and click Save.
- Repeat for any other profiles that require visibility into ScreenMeet session related lists.
Step 6: Configure the Page Layout
- Navigate to a record of the target object type (for example, an Opportunity).
- Click the Gear icon in the top right and select Edit Object.
- Click Page Layouts and open the layout you want to update.
- 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.
- 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
- Set Sort By to ScreenMeet Live Session: Created Date and Order to Descending.
- Click OK, then click Save.