CMTD Enhanced Related List
by Salesforce Labs
User Guide - v2.6
March 2020
Installations
Installations
Version 2.0 - Package Components
Installations
Version 2.0
Once installed, “CMTD Enhanced
Related List” component is
available in App Builder
Use “Enhanced Related List”
Custom Metadata Type to
configure the fields
Sample configuration:
Simply drag the component into
Account page (ensure Account
has some Case records)
Leave all the attributes as default
Component Configurations
Component Attributes
Component Configurations
Component Attributes
Attribute Name Attribute API Name Description
Parent Object Id Field parentObjectIdField The API name of the Id field in the Parent object.
By default(or when it is empty) it uses the record Id of the Parent Object
Only update
Object API Name* objectAPIName API name of the Object whose records will be displayed. When showing related
Cases on an Account record page, this value is Case.
Related List Name* relatedListName This is a unique identifier for the component. It must match the "Related List Name" in
the “Enhanced Related List” Custom Metadata Type records.
Parent Field in Child
Object*
parentField The API name of the field on the Child Object (Object API Name) that holds the
record Id of the parent. When showing related Cases on an Account, the value is
AccountId (Case object’s AccountId field)
*
required
Component Configurations
Component Attributes
Attribute Name Attribute API Name Description
Records Display Type displayType Display mode to display the records.
List = Display records in List.
Tile 1 = Display records in 1 column Tile.
Tile 2 = Display records in 2 columns Tile.
Fields Layout Type layoutType The layout of fields in the body when Records Display Type = "Tile 1" or "Tile 2"
1 Column = Fields are displayed in 1 column layout
2 Columns = Fields are displayed in 2 columns layout
Filter filter Filter criteria for the object. Eg: Status = 'Open'
Sort sort Sort mode for the object. Syntax = Field API Name and ASC/DESC. eg: Created
DESC. For multiple sorting, use ‘,’ (eg: Created DESC, Amount DESC)
Note: Please use sorting in consideration as it will impact performance.
Default Number of
Records to Display
defaultNumberofRecordsTo
Display
Number of records displayed when the component is loaded
Max Number of Records
to Display
maxNumberofRecordsToDi
splay
Maximum number of records that can displayed. Recommended:50 Limit:500
Title title Title of the component
Icon Name iconName Icon for the title. This is using SLDS icon. Syntax = category:icon name. Eg:
standard:case
Component Configurations
Component Attributes
Attribute Name Attribute API Name Description
New Record newRecord Valid value = Standard, StandardWithRecordType, Custom LC Name or leave it
blank. Note: The value is case sensitive.
Leave blank would hide the New button.
Standard: New record creation without record type. If the object has a record
type it will use profile’s default record type (or “Default Record Type” when
provided)
StandardWithRecordType: New record creation with record type selection.
When “Default Record Type” is provided, it will be pre populated.
Provide custom LC name (case sensitive) when additional functionality is
required eg: setting default value on creation (please refer to Advanced Mode)
Default Record Type defaultRecordType Default record type to be selected or populated when 'New Record' attribute is used.
The value should be the Record Type Label available for the object.
Show Header? showHeader Display/hide the component header. If this attribute is set to false, 'New' record
functionality will not be available
Show Refresh Button? showRefreshButton Display/hide the refresh button
Show Menu Action? showMenuAction Display/hide the Menu Action (eg: Edit/ Delete items)
Component Configurations
Component Attributes
API name of the Object
whose records will be
displayed
Must match with the
‘Enhanced Related List’
CMT
The API name of the field on the
Child Object (Object API Name)
that holds the record Id of the
parent.
The API name of the Id field
in the Parent object.
Component Configurations
“Enhanced Related List” Custom Metadata Type
Component Configurations
“Enhanced Related List” Custom Metadata Type
Attribute Name Data Type Description
(Enhanced Related List)
Name*
Text Unique record identifier. Recommended naming convention: Related List Name + “_” +
Label. This is a standard field.
Label* Text Label to display for the field in CMTD Enhanced Related List component.
This is a standard field.
Related List Name* Text Related List Name as specified in "Related List Name" attribute of the individual CMTD
Enhanced Related List component in App Builder.
Field API Name* Text Field API Name of the object as specified in "Object API Name" attribute of the CMTD
Enhanced Related List component
Reference Field syntax: referenceField__c.FieldName__c
Examples (on Case object):
Display Account Name: AccountId.Name
Display Case Creators Username: CreatedById.Username
Display Account’s Creator’s Username: AccountId.CreatedById.Username
Header Checkbox Used to display fields in the header section when using Tile display mode
Order Number Sequence to display the fields in the component
*
required
Component Configurations
“Enhanced Related List” Custom Metadata Type
Attribute Name Data Type Description
UI Type Override Picklist To override the UI display of the field.
Checkbox: to display a checkbox field (Boolean) using a checkbox icon
Badge: To highlight important text
Badge will only display when the field value is not empty.
Hint: Use formula field (text) to display a value that meet certain criteria
eg: If(IsEscalated, "Escalated","")
Unescaped HTML: To display any rich text or any formula fields that uses HTML
Colour Text Colour for Badge UI Type Override - only accept HEX
Target API Name Text When populated, the field value will have a hyperlink (only support Salesforce record Id).
Provide field API Name of the Id of the target record.
Inactive Checkbox Flag to indicate if the CMT record is used. When this field is checked, the CMT record will be
ignored and the field will not be displayed in the component.
*
required
Component Configurations
“Enhanced Related List” CMT
Each Custom Metadata Type (CMT) record represents a single column and its configuration
that will be displayed in the component.
Must be unique
across all records
Hint: Create your own list view
for each “Related List Name”
to manage your data
Please ensure to
provide the correct
field API name
For hyperlink.
Specify field API
name that holds
Salesforce record Id
Must match the
value configured in
App Builder for the
component
When the component is added in the AppBuilder, the default values of the attributes uses
these sample data below (Note: the records below are used but will not be visible).
Please create your own records to start using the component
Component Configurations
“Enhanced Related List” CMT Record Creations
To start creating the "Enhanced Related List" Custom Metadata Type records:
1. In Setup, type "meta" and select "Custom Metadata Types"
2. Click on "Manage Records" on the "Enhanced Related List"
Note: Follow the Examples provided in the AppExchange listing for some sample use cases
Component Configurations
Providing Access
Component Configurations
Providing Access
Options:
1. Add ‘CMTD ERL Permission Set’ to the users who need access to the App, or
2. Add the following classes in the user profile/ permission set. You may need to enable
‘Enhance Profile User Interface’ to add the classes.
a. CMTD.EnhancedRelatedList_CC
b. CMTD.ERL_RecordNavigation_CC
c. CMTD.ERL_RTSelector_CC
Note:
This step is needed after activating Critical Update below:
Restrict Access to @AuraEnabled Apex Methods for Guest and Portal Users Based on User Profile
Restrict Access to @AuraEnabled Apex Methods for Authenticated Users Based on User Profile
Advanced Mode
Advanced Mode
1. Parent Object Id Field
When to use:
Display the related list on the Lightning Record page using Id field other than Record Id
Sample use case:
1. Case record page, display a list of Open Opportunities for the same Account.
Parent Object Id Field: AccountId
Object API Name: Opportunity
Parent Field in Child Object: AccountId
2. Case record page, display Related Cases for the same Contact
Parent Object Id Field: ContactId
Object API Name: Case
Parent Field in Child Object: ContactId
This would be AccountId on the Case object
This would be AccountId on the Opportunity object
This would be ContactId on the Case object (Parent Object)
This would be ContactId on the Case object (Child Object)
Advanced Mode
2. Custom LC Wrapper
When to use:
Display the related list in Lightning Home page
Display the related list from Custom Lightning Component
Use parentId attribute (Hidden - not available in App Builder):
pass the value of the Id to match with the ‘Parent Field in Child Object’
Advanced Mode
2. Custom LC Wrapper - Cont’d
Sample use case:
1. Display My Open Cases on the Home Page
homeMyOpenCases.cmp (sample only)
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" access="global" >
<aura:attribute name="userId" type="String" />
<aura:attribute name="showComponent" type="Boolean" default="false" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:if isTrue="{!v.showComponent}">
<CMTD:EnhancedRelatedList objectAPIName="Case" relatedListName="Test Open Cases"
parentField="OwnerId" parentId="{!v.userId}"
displayType="Tile 1" layoutType="1 Column"
sort="CreatedDate DESC" filter="Status!='Closed'"
defaultNumberofRecordsToDisplay="2" title="My Open Cases"
iconName="standard:case"
showHeader="true" showRefreshButton="true" />
</aura:if>
</aura:component>
homeMyOpenCases.js (sample only)
({
doInit : function(component, event, helper) {
var userId = $A.get("$SObjectType.CurrentUser.Id"); // hint: call server controller for other fields
component.set("v.userId", userId);
component.set("v.showComponent", true);
}
})
Advanced Mode
2. Custom LC Wrapper - Cont’d
2. Custom Lightning Component
Customer 360 - display dynamic related list based on certain selections
Check out sample usage by my colleague on his blog
https://cloudmatters.blog/2018/11/04/lighting-out-visualforce-lightning-printing/
Advanced Mode
3. Override New Record using custom LC
‘New Record’ component attribute support custom LC
Sample use cases:
Set default fields on New record. Eg: New case creation, pre populate Contact field with Primary Contact
of the Account.
Prompt users with some selections before navigating to standard Case creation page layout
The custom LC must implement the following attributes.
<aura:attribute name="parentFieldName" access="global" type="String" />
It will be populated with the value of parentField attribute from “CMTD Enhanced Related List”
<aura:attribute name="parentFieldId" access="global" type="String" />
It will be populated with the value of the parent record used in the “CMTD Enhanced Related List”
Custom LC to utilise the attributes above to retrieve necessary information on init method.
Custom LC is responsible to display the UI and create new record
Advanced Mode
Override New Record using custom LC - Sample
caseRecordTypeSelector custom component
AccountId is set in parentId attribute and
the Account record Id is available for this
component
On init, it perform SOQL to retrieve the
Primary Contact of the Account and set
the value
Troubleshooting
Troubleshooting
Error/ Issue Resolution
CMTD_ERL Related List Name: abc - No
configuration found
Unable to find records in CMT where Related List Name = ‘xyz’. Please check the
‘Related List Name’ attribute in the component and ‘Related List Name’ in CMT. Make
sure they match.
Invalid Object API Name abc The field API name for the Object is incorrect. Please check the Component Attributes
No such Field abc on xyz Object The field API name for the Field is incorrect. Please check the Component Attributes
and Custom Metadata Type configuration
No COMPONENT named markup://c:standard found Please check “New Record” Component Attributes. The value is case sensitive.
Slow in loading the records This component uses SOQL to retrieve the data based on the fields provided in the
CMT.
Please review the query by generating the SOQL listing all the fields (incuding filter and
sort). Reduce number of fields or apply index as required.
Access Check Failed! AttributeSet.set():... Disable Lightning Debug mode
Version History
Version History
2.6
Added ‘CMTD ERL Permission Set’ that can be added for the users who need access to the
app
2.5
Updated Apex version to 47 to support new objects that requires newer API version (eg:
Financial Service Cloud object)
Support default NamePointing reference that uses common field name (eg: on Case object
OwnerId.Name)